[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] not defined $j || scalar @$j == 0



$ 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@petdance.com => www.petdance.com => AIM:petdance