in reply to and this or that
(Updated to add error handling after readdir(), too.)for my $next (@ARGV){ opendir(PWD, "$next") or die "$next: $!"; my @files = readdir(PWD) or die "$next: $!"; closedir(PWD); print join("\n", @files), "\n"; }
Or, if you really want to use precedence, and if you want to ignore non-directories in @ARGV, consider
for my $next (@ARGV) { opendir(PWD, "$next") and do { my @files = readdir(PWD) or die "$next: $!"; closedir(PWD); print join("\n", @files), "\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: and this or that
by Fastolfe (Vicar) on Feb 06, 2001 at 01:01 UTC |