On Wed, 27 Nov 2002 04:41:13 +0000, Paul Makepeace wrote:
>$ perl -Mstrict -le 'print "one" if (my $d = "1") && $d'
>
>[or indeed if ((my $d = "1") && $d) {...} ]
>
>perl apparently doesn't consider $d exists by the second $d and issues
>an error. Can someone explain this? (Esp. in light of all this sequence
>point talk.)
Let me show another example.
my $d = 'outside';
print do {
(my $d = 'inside') && $d;
};
or even
my $d = 'inside' and $d;
instead.
These both print 'outside' (as well as producing a warning about the
"=" in the conditional, because the RHS is a constant), so, even though
the inner scoped $d got assigned to already, in the rest of the same
statement, it's still the outer scoped $d that is visible.
Now, in your case, you don't have an outer scoped $d, so perl/strict
consider it not to exist.
--
Bart.