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

[Omaha.pm] Precedence && vs or



Huh. This was dying when $last_elt wasn't defined:

$last_elt->paste(last_child => $controls) or die;

So I changed it to this:

$last_elt && $last_elt->paste(last_child => $controls) or die;

Thinking the && would short-circuit the rest if $last_elt wasn't
defined. It doesn't. Here's a demo:

--------
$ cat j.pl
my $j;
$j && $j->what or die;

$ perl j.pl
Died at j.pl line 4.
--------

Oops. Adding parens gets me to the behaviour I expected:

--------
$ cat j.pl
my $j;
$j && ($j->what or die);

$ perl j.pl
$
--------

Live and learn.  :)

j