Thread Namen von Verzeichnissen auslesen
(17 answers)
Opened by Gast at 2005-10-06 17:12
So geht es z.B. rekursiv:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 my @files; sub findFiles($) { my ($dir) = @_; my $dirhandle; opendir($dirhandle, $dir) || die "can't opendir $dir: $!"; foreach my $entry (readdir($dirhandle)) { if ($entry !~ m{^\.\.?$}) { my $absentry = $dir . '/' . $entry; if (-f $absentry) { push @files, $absentry; } elsif(-d $absentry) { findFiles($absentry); } } } closedir($dirhandle); } Gruß
Thomas |