OK LanX,Eily,roboticus, thanks I understand it now: The hash contents are a single statement (re: the comma) which is parsed and its elements are pushed into a stack. But $m is a reference so although its value is updated correctly, the reference pushed in the stack is always the same. So it's only the last value which will prevail. Same with ++$m. But not for $m++ which, I guess, it has to create a temporary variable to store its effect and that is what's pushed into the stack. Which is also the trick used by LanX.
perlfan A reason I use the sequence of exists and defined is to avoid autovivification, which will appear when I use deeper levels. I know I can turn it off... (btw that's not a "sane" default!!!)
Question: the if-statement is safe as (I guess) it evaluates each sub-conditional to a true-false and does not stack the variables? e.g. if( exists($h->{1}) && defined($m=$h->{1}) && ($m==1) && defined($m=$h->{2}) && ($m==2) ){ ... }
In reply to Re: Ternary Quizical behaviour?
by bliako
in thread Ternary Quizical behaviour?
by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |