[Omaha.pm] not defined $j || scalar @$j == 0
Andy Lester
andy at petdance.com
Mon Apr 10 06:12:00 PDT 2006
> $ cat j.pl
> use strict;
>
> my $j;
> if (not defined $j || scalar @$j == 0) {
> print "yup\n";
> }
It's a precedence issue. What you've got there is
if ( (not ( (defined $j) || (scalar @$j == 0) ) )
Use parentheses.
my $j;
if ((not defined $j) || (scalar @$j == 0)) {
print "yup\n";
}
Or even more idiomatically:
if ( !$j || !@$j )
xoxo,
Andy
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
More information about the Omaha-pm
mailing list