Bart Lateur said: > 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.
Yes, this is a feature, and is documented in perlsub. It lets you write my $d = $d; should you so wish. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net