Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This chunk of code, using READDIR, nicely reads in the
contents of the top level the directory, places it into
an array then prints it back out. However, READDIR on
Win32 ( and everywhere else I would assume) does NOT read
into the sub-directories. Just the top level. How does
one accomplish this?
#!/usr/bin/perl -w use strict; use FileHandle; my $localdir="c:\\temp"; opendir LOCALDIR, "$localdir"; my @local_files = grep !/^\.\.?$/, readdir LOCALDIR; closedir LOCALDIR; my $n=@local_files; for (my $i=0; $i<$n; $i++){ print "$local_files[$i]\n"; }
Back to
Seekers of Perl Wisdom