Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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 ...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 17:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found