]> Frank Brehm's Git Trees - scripts/solaris.git/commitdiff
POD-Doku, POD::Usage und Optionen dazu
authorFrank Brehm <frank@brehm-online.com>
Tue, 18 Sep 2007 07:56:46 +0000 (07:56 +0000)
committerFrank Brehm <frank@brehm-online.com>
Tue, 18 Sep 2007 07:56:46 +0000 (07:56 +0000)
get-perl-modules.pl

index 665c88bdf2a98c550e57789d08fe7a4f690e3ef6..fd744e1b6b3d114743b0d729053feecf3535ec12 100755 (executable)
 # $Id$
 # $URL$
 
+=head1 NAME
+
+B<get-perl-modules.pl> - Stellt eine Liste aller verfuegbarer Perl-Module zusammen.
+
+=head1 SYNOPSIS
+
+B<get-perl-modules.pl> [OPTIONS]
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-v> - Verbose-Level (Debug-Level)
+
+Wird durch Mehrfach-Aufzaehlung erhoeht.
+
+=item B<-D level> - Debug-Level
+
+Numerische Angabe des Debug-Levels.
+
+I<Hinweis>:
+
+Die Parameter C<-v> und C<-D> wirken sich gleich aus.
+Wenn beide angegeben werden, wird der hoehere von beiden verwendet.
+
+=item B<--help>
+
+=item B<-h>
+
+=item B<-?>
+
+Gibt diesen Hilfebildschirm aus und beendet sich.
+
+=item B<--version>
+
+=item B<-V>
+
+Gibt die Versionsnummer dieses Programms aus und beendet sich.
+
+=back
+
+=cut
+
 use strict;
+use 5.8.0;
 use warnings;
 
 use File::Find;
 use File::Spec;
 use Data::Dumper;
 use Config;
+use Pod::Usage;
+use Getopt::Long;
 
 $Data::Dumper::Indent = 1;
 $Data::Dumper::Sortkeys = 1;
+Getopt::Long::Configure('bundling');
 
 $| = 1;
 
+my $Revisn = <<'ENDE';
+ $Revision$
+ENDE
+$Revisn =~ s/^.*:\s*(\S+)\s*\$.*/$1/s;
+our $VERSION = "1.0." . $Revisn;
+
+
 my $module = {};
 
-my $cur_dir;
+my ( $verbose, $cur_dir, $cmdline_verbose, $DebugLevel, $help, $show_version );
+
+unless (
+    GetOptions(
+        "verbose|v+"           => \$cmdline_verbose,
+        "DebugLevel|Debug|D=i" => \$DebugLevel,
+        "help|h|?"             => \$help,
+        "version|V"            => \$show_version,
+    )
+  )
+{
+    pod2usage( { -exitval => 1, -verbose => 1 } );
+} ## end unless ( GetOptions( "conf|config|c=s"...
+
+$cmdline_verbose ||= 0;
+$cmdline_verbose = $DebugLevel if $DebugLevel and $DebugLevel > $cmdline_verbose;
+$verbose = $cmdline_verbose;
+
+if ($help) {
+    $verbose ? pod2usage( -exitstatus => 1, -verbose => 2 ) : pod2usage(1);
+}
+
+if ($show_version) {
+    print "Version $0: " . $VERSION . "\n";
+    print "\n";
+    exit 0;
+}
 
 my $arch = $Config{'archname'};
 my $version = $Config{'version'};
@@ -26,7 +106,7 @@ my $version = $Config{'version'};
 for my $dir ( @INC ) {
 
     if ( -d $dir ) {
-        print "\nDurchsuche Verzeichnis '$dir' ...\n";
+        print "\nDurchsuche Verzeichnis '$dir' ...\n" if $verbose;
         $cur_dir = $dir;
         find( \&wanted, $dir );
     }
@@ -36,7 +116,7 @@ sub wanted {
 
     my $file_abs = $File::Find::name;
     if ( -f $file_abs and $file_abs =~ /\.pm$/ ) {
-        # print "Untersuche '$file_abs' ...\n";
+        print "Untersuche '$file_abs' ...\n" if $verbose > 1;
         
         my ( $volume, $file_in_volume, $file_bla ) = File::Spec->splitpath( $file_abs, 1 );
         $file_in_volume =~ s/^$cur_dir\///;
@@ -45,15 +125,51 @@ sub wanted {
         my $modname = $file_in_volume;
         $modname =~ s/\.pm$//;
         $modname =~ s#/#::#g;
-        # print "Modul '$modname' gefunden in '$cur_dir' ...\n";
+        print "Modul '$modname' gefunden in '$cur_dir' ...\n" if $verbose > 1;
         $module->{$modname} = 1;
     }
 
 }
 
-# print Dumper( $module );
+print Dumper( $module ) if $verbose > 1;
+
+print "\nGefundene Module:\n\n" if $verbose;
 
 for ( sort { lc($a) cmp lc($b) } keys %$module ) {
-    print " - $_\n";
+    print " - " if $verbose;
+    print "$_\n";
 }
 
+exit 0;
+
+#------------------------------------------------------------------------------------
+
+__END__
+
+=end comment
+
+=head1 DESCRIPTION
+
+Stellt aus allen Modul-Verzeichnissen (@INC) eine Liste der verfuegbaren Perl-Module
+zusammen (unabhaengig davon, ob sie funktionieren).
+
+=head1 FILES
+
+Keine.
+
+=head1 SEE ALSO
+
+=over 1
+
+=item I<perl>(8)
+
+=item I<perlmod>
+
+=back
+
+=head1 AUTHOR
+
+Frank Brehm <frank@brehm-online.com>
+
+=cut
+