On 12/15/09 Tue  Dec 15, 2009  4:49 PM, "Shawn H Corey"
<shawnhco...@gmail.com> scribbled:

> Steve Bertrand wrote:
>> my $month = $ARGV[0] if $ARGV[0];
> 
> $ cat myscript.pl
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> my $month = $ARGV[0] if $ARGV[0];
> print "$month\n";
> $ ./myscript.pl
> Use of uninitialized value $month in concatenation (.) or string at
> ./myscript.pl line 7.
> 
> 
> 
> Try:
> my $month = '';
> $month = $ARGV[0] if $ARGV[0];
> 

Or try:

my $month = ( @ARGV ? $ARGV[0] : '' );

which allows you to enter '0' as an argument.



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to