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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.