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

Jay Hannah jhannah at omnihotels.com
Mon Apr 10 04:18:27 PDT 2006


Doh. "use strict" pukes even when a short-circuit operator stops the
right side from being evaluated...

I was trying to have my if test below trap when
   (1) $j is undef
   (2) $j is [ ]

But apparently "use strict" is too... mmm... strict.

j


$ cat j.pl
use strict;

my $j;
if (not defined $j || scalar @$j == 0) {
   print "yup\n";
}

$ perl j.pl
Can't use an undefined value as an ARRAY reference at j.pl line 4.



More information about the Omaha-pm mailing list