|Perl Monk, Perl Meditation|
Using ternary operator as lvalue in pushby oha (Friar)
|on Jul 31, 2007 at 15:22 UTC||Need Help??|
oha has asked for the wisdom of the Perl Monks concerning the following question:
In another node i was replying and i wrote a piece of code which was not working. after some changes i made it work but i didn't figured out why wasn't. after some meditation i came up asking a friend, and seems like what didn't worked for me, worked for him.
i knew (but i checked perlop) that the ternary operator can be used as an lvalue (e.g.: $cond ? $a : $b = 0) and i expected it had worked on push too:
but the compiler complains (complaier?):
Type of arg 1 to push must be array (not null operation) at ...
works as expected.
since my friend is serious enough, have i to think it works in other version of perl? (mine 5.8.4)
PS: that's what i like of perl and perlmonks, trying to answer someone question i got a brand new one. :)