develooper Front page | perl.perl5.porters | Postings from August 2009

Ret val of assigning to a list containing undef

From:
Eric Brine
Date:
August 25, 2009 11:54
Subject:
Ret val of assigning to a list containing undef
Message ID:
f86994700908251154r1852b05bgea18711476db0bc8@mail.gmail.com
When a LHS element of a list assignment is immortal, Perl pretends the
RHS element is on the LHS for the purpose of building the return
value.

$ perl -wle'$x="xx";$y="yy"; $_=uc for ($y)=$x; print "$x$y"'
xxXX

$ perl -wle'$x="xx";$y="yy"; $_=uc for (undef)=$x; print "$x$y"'
XXyy

It's probably not worth the effort of fixing it, so I'm just posting
it as a "FYI".

By the way, the trick of using undef on the right-hand side of a list
assignment is not mentioned in perlop.

- Eric "ikegami" Brine



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About