![]() |
|
more useful options | |
PerlMonks |
Re^3: What is true and false in Perl?by tobyink (Canon) |
on Oct 18, 2012 at 02:26 UTC ( #999654=note: print w/replies, xml ) | Need Help?? |
That's not quite true. Observe:
The reason for this behaviour is that if imposes a scalar context on the expression that acts as its condition. When the comma operator is used in a scalar context it is not a list constructor and instead evaluates the left argument, discards it and then evaluates the right argument (it basically acts like the semicolon but with a different precedence). Thus this:
Is essentially the same as:
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Tutorials
|
|