Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: and this or that

by Fastolfe (Vicar)
on Feb 06, 2001 at 01:01 UTC ( [id://56501]=note: print w/replies, xml ) Need Help??


in reply to Re: and this or that
in thread and this or that

for my $next (@ARGV) { opendir(PWD, "$next") and do { my @files = readdir(PWD) or die "$next: $!"; closedir(PWD); print join("\n", @files), "\n"; } }
TIMTOWDI. I personally find this a little clearer, and is no less idiomatic:
foreach my $next (@ARGV) { if (opendir(PWD, "$next")) { my @files = readdir(PWD) or die "$next: $!"; closedir(PWD); print join("\n", @files), "\n"; } }
While using and and do like that is only slightly less clear than using a true 'if' block, it is slightly less clear than using a true 'if' block. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://56501]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 14:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found