Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Copying a value from an element in the ARGV array to a variable...

by mr.nick (Chaplain)
on Sep 17, 2001 at 20:02 UTC ( [id://112886] : note . print w/replies, xml ) Need Help??


in reply to Copying a value from an element in the ARGV array to a variable...

Just to build on arturo's comment of using the ternary || operator: if you have (or plan to have) multiple arguments, then something along these lines might work better for you:
my $date = @ARGV ? shift @ARGV : yesterday();
That way you can easily inline other arguments:
my $arg1 = @ARGV ? shift @ARGV : 'default value'; my $date = @ARGV ? shift @ARGV : yesterday(); my $arg2 = @ARGV ? shift @ARGV : 'other value';

mr.nick ...