#!/usr/bin/perl use strict; use warnings; my @files; my @ignore=( '/usr/bin/', '/home', ); iterate_dirs( # entscheiden ob das Verzeichnis besucht werden soll sub{ for(@ignore) { return 0 if( index($_[1],$_)==0 ); } return 1 if( -r $_[0] ); return 0; }, # Auswerten des Eintrags sub{ push(@files, $_[1]) if( -f $_[0] and -r $_[0] and substr($_[0],-4,4) eq '.pod' ); }, # die zu durchsuchenden Verzeichnisse '/usr/lib/perl5' ); print "$_\n" for( @files ); ################################# sub iterate_dirs { my ($decide_code, $each_code, @stack ) =@_ ; my $dir=getcwd; my ($p,$dh,$path,$tmp); while(@stack) { $path = pop(@stack); chdir( $path ) or die "chdir($path) failed: $!";; opendir( $dh, '.' ) or die "Unable to open $path: $!\n"; for( readdir( $dh ) ) { next if( $_ eq '.' or $_ eq '..' ); $tmp=$path.'/'.$_; push(@stack, $tmp) if( -d $_ and $decide_code->( $_, $tmp ) ); $each_code->( $_, $tmp ); } closedir ($dh); } chdir ( $dir ) or die "chdir($dir) failed: $!\n"; return 1; }