PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/pmtools-1.10/pminst

#
Perl | 159 lines | 120 code | 35 blank | 4 comment | 11 complexity | ac37e2addee62f6289d7f7575a9ab78a MD5 | raw file
  1. #!/usr/bin/perl
  2. # pminst -- find modules whose names match this pattern
  3. # tchrist@perl.com
  4. BEGIN { $^W = 1 }
  5. use Getopt::Std qw(getopts);
  6. use File::Find;
  7. getopts('ls') || die "bad usage";
  8. if (@ARGV == 0) {
  9. @ARGV = ('.');
  10. }
  11. die "usage: $0 [-l] [-s] pattern\n" unless @ARGV == 1;
  12. $pattern = shift();
  13. $pattern =~ s,::,/,g;
  14. no lib '.';
  15. use vars qw($opt_l $opt_s);
  16. for $startdir (@INC) {
  17. find(\&wanted, $startdir);
  18. }
  19. sub wanted {
  20. if (-d && /^[a-z]/) {
  21. # this is so we don't go down site_perl etc too early
  22. $File::Find::prune = 1;
  23. return;
  24. }
  25. return unless /\.pm$/;
  26. local $_ = $File::Find::name;
  27. ($tmpname = $_) =~ s{^\Q$startdir/}{};
  28. return unless $tmpname =~ /$pattern/o;
  29. if ($opt_l) {
  30. s{^(\Q$startdir\E)/}{$1 } if $opt_s;
  31. }
  32. else {
  33. s{^\Q$startdir/}{};
  34. s/\.pm$//;
  35. s{/}{::}g;
  36. print "$startdir " if $opt_s;
  37. }
  38. print $_, "\n";
  39. }
  40. __END__
  41. =head1 NAME
  42. pminst - find modules whose names match this pattern
  43. =head1 SYNOPSIS
  44. pminst [B<-s>] [B<-l>] [I<pattern>]
  45. =head1 DESCRIPTION
  46. Without argumnets, show the names of all installed modules. Given a
  47. pattern, show all module names that match it. The B<-l> flag will show
  48. the full pathname. The B<-s> flag will separate the base directory from
  49. @INC from the module portion itself.
  50. =head1 EXAMPLES
  51. $ pminst
  52. (lists all installed modules)
  53. $ pminst Carp
  54. CGI::Carp
  55. Carp
  56. $ pminst ^IO::
  57. IO::Socket::INET
  58. IO::Socket::UNIX
  59. IO::Select
  60. IO::Socket
  61. IO::Poll
  62. IO::Handle
  63. IO::Pipe
  64. IO::Seekable
  65. IO::Dir
  66. IO::File
  67. $ pminst '(?i)io'
  68. IO::Socket::INET
  69. IO::Socket::UNIX
  70. IO::Select
  71. IO::Socket
  72. IO::Poll
  73. IO::Handle
  74. IO::Pipe
  75. IO::Seekable
  76. IO::Dir
  77. IO::File
  78. IO
  79. Pod::Functions
  80. The -s flag provides output with the directory separated
  81. by a space:
  82. $ pminst -s | sort +1
  83. (lists all modules, sorted by name, but with where they
  84. came from)
  85. $ oldperl -S pminst -s IO
  86. /usr/lib/perl5/i386-linux/5.00404 IO::File
  87. /usr/lib/perl5/i386-linux/5.00404 IO::Handle
  88. /usr/lib/perl5/i386-linux/5.00404 IO::Pipe
  89. /usr/lib/perl5/i386-linux/5.00404 IO::Seekable
  90. /usr/lib/perl5/i386-linux/5.00404 IO::Select
  91. /usr/lib/perl5/i386-linux/5.00404 IO::Socket
  92. /usr/lib/perl5/i386-linux/5.00404 IO
  93. /usr/lib/perl5/site_perl LWP::IO
  94. /usr/lib/perl5/site_perl LWP::TkIO
  95. /usr/lib/perl5/site_perl Tk::HTML::IO
  96. /usr/lib/perl5/site_perl Tk::IO
  97. /usr/lib/perl5/site_perl IO::Stringy
  98. /usr/lib/perl5/site_perl IO::Wrap
  99. /usr/lib/perl5/site_perl IO::ScalarArray
  100. /usr/lib/perl5/site_perl IO::Scalar
  101. /usr/lib/perl5/site_perl IO::Lines
  102. /usr/lib/perl5/site_perl IO::WrapTie
  103. /usr/lib/perl5/site_perl IO::AtomicFile
  104. The -l flag gives full paths:
  105. $ filsperl -S pminst -l Thread
  106. /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Queue.pm
  107. /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Semaphore.pm
  108. /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Signal.pm
  109. /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Specific.pm
  110. /usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread.pm
  111. =head1 AUTHORS and COPYRIGHTS
  112. Copyright (C) 1999 Tom Christiansen.
  113. Copyright (C) 2006-2008 Mark Leighton Fisher.
  114. This is free software; you can redistribute it and/or modify it
  115. under the terms of either:
  116. (a) the GNU General Public License as published by the Free
  117. Software Foundation; either version 1, or (at your option) any
  118. later version, or
  119. (b) the Perl "Artistic License".
  120. (This is the Perl 5 licensing scheme.)
  121. Please note this is a change from the
  122. original pmtools-1.00 (still available on CPAN),
  123. as pmtools-1.00 were licensed only under the
  124. Perl "Artistic License".