Ron Smith wrote:
>
> 5 if (@ARGV) {
> 6 foreach $ARGV (@ARGV) {
> 7 opendir (DIR, "$ARGV") or die "$!";
> 8 }
> 9 }
>
> So far, it looks like the last command-line argument is stepping on any other
> arguments that come before it. Is there a way to assign multiple command-line
> args to multiple directory handles?
If you have Perl version 5.6 or newer then you can use lexically scoped
directory handles.
die "usage: $0 list of directorys\n" unless @ARGV;
for my $dir ( @ARGV ) {
opendir my $dh, $dir or die "Cannot open $dir: $!";
my @files = grep !/^\.\.?$/, readdir $dh;
# do something with @files
closedir $dh;
}
Of course if you are reading directories recursively then you should
probably use the File::Find module.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]