5.10 throws a warning for that type of constructNo it doesn't. I seem to recall that blead did, at some point, but it appears to no longer do so.
I constantly wonder why it is not an error at all. Whatever its behaviour could be in an actual implementation, I can see no logical nor intuitive semantics that could be attached to the construct. It has a meaning to do something upon a condition. How can have a meaning for a thingie to exist or not, upon a condition? Point is, declaration happens at compile time, condition is verified at runtime. "Ideally" one could expect that in statements following
my $var=whatever if condition;
$var would be the lexical one just declared if condition is true, and something else (as if the declaration just were not there) otherwise: clearly, any way you look at it, it's unsatisfactory.
In reply to Re^3: Curious result of using "my ... if ..."
by blazar
in thread Curious result of using "my ... if ..."
by jrw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |