doom's explanation is wrong. It has nothing to do with order. Even if you fixed the order, it still wouldn't work.
(my $t = shift) and print $t; # Fails.
Variables cannot be used (by name) in the statement in which they are declared. This allows statements such as my $t = $t; to work.
print $t if (my $t = shift); # Fails. my $t = shift; print $t if $t; # Ok. if (my $t = shift) { print $t; } # Ok.
In reply to Re^3: Duh. 'my' scope in if else blocks.
by ikegami
in thread Duh. 'my' scope in if else blocks.
by gam3
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |