> It's worth noting that if the two forms are equivalent, the latter is probably a lot less confusing when the output value is used.
It's also worth noting that B::Deparse can't always be trusted.
The clause of the if has the same scope like the inner block ( with if (CLAUSE) {BLOCK} )
DB<3> use strict; my $x=3; if (my $x =1) { print $x }
1
DB<4> use strict; if (my $x =1) { print $x }; print $x
Global symbol "$x" requires explicit package name (did you forget to d
+eclare "my $x"?) at (eval 13)[C:/Perl_524/lib/perl5db.pl:737] line 2.
DB<5>
but Deparse fails to cover this with -x7
>>perl -MO=Deparse,-x7 -e"if (my $x =1) { print $x }; print $x"
my $x = 1 and do {
print $x
};
print $x; # <-- no error under strict!
-e syntax OK
|