Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
laziness, impatience, and hubris
 
PerlMonks  

Re: The or thing.

by Mandrake (Chaplain)
on Feb 17, 2006 at 06:53 UTC ( #530872=note: print w/ replies, xml ) Need Help??


in reply to The or thing.

One small modification:

#!/usr/bin/perl -w if (eval join (" or ", map {$_=" -e '".$_ ."'"}@ARGV)) { print "Hooray at least one of the the files exists"; } else { print "Hohum neither of the files exist"; }
This will accept any number of files (instead of two). Provide the file names as command line arguments.
Thanks..


Comment on Re: The or thing.
Download Code
Re^2: The or thing.
by Anonymous Monk on Feb 17, 2006 at 08:22 UTC
    eval-ing @ARGV is dangrous, perldoc perlsec
Re^2: The or thing.
by Fletch (Chancellor) on Feb 17, 2006 at 13:53 UTC

    Why bother with eval?

    if( grep -e $_, @ARGV ) { print "At least one file exists\n"; } else { print "None exist\n"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2013-05-23 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (484 votes), past polls