"be consistent" | |
PerlMonks |
Re: uninitialized variableby arturo (Vicar) |
on Feb 28, 2001 at 04:04 UTC ( [id://61240]=note: print w/replies, xml ) | Need Help?? |
$location = shift(@ARGV); will set $location to undef if no arguments have been passed to the script (@ARGV refers only to the command line, as bbfu points out). That's why you're getting the warning.
For cases like these, you can either do:
or, if you want a default,
Minor amplification shift called without an explicit argument will return the next element of @ARGV if it is called outside a subroutine, and returns the next element of @_ if called within a subroutine. HTH Philosophy can be made out of anything. Or less -- Jerry A. Fodor
In Section
Seekers of Perl Wisdom
|
|