With due respect to ikegami and all other monks, I strongly disagree with ikegami for the following reasons.

  1. How will you explain the peculiar behavior I have explained in my post Re: print behavior when we have more than one $x++ in same print statement ? ( the table is appended below for reference.

    Print orderO/P in Perl
    $x0
    $x,$x++10
    $x,$x,$x++110
    $x,$x++,$x++201
    $x,$x++,$x++,$x++3012
    $x,$x++,$x++,$x++,$x++40123
    $x,$x++,$x++,$x++,$x++,$x++501234

  2. How we have the similar behaviour with "C" where printf("%d%d",x,x++) which will also print 10?
  3. you said "print will see the change in $x caused by ++ (which must be evaluated before print is called)." Then why
    my $x =0; print $x++; #prints 0 print $x++; #prints 1
    works properly? Why in this case $x++ is NOT incrementing $x before print is called?
  4. Given $x=0, @_ is ($x, $anon) which evaluates to (1, 0). --- Can you explain how the @_ is evaluated to ( 1, 0 ) ?
  5. arguments are passed by reference --- if its passed by reference, how will you explain this behaviour for all function calls? including user-defined-functions? (see comments in my post Re: print behavior)

If you keep the explanation I posted at Re: print behavior in mind, there is NO harm in modifying a variable in a parameter list expression when the variable appears elsewhere in that parameter list. Isn't it a nice obfuscation.


In reply to Re^2: print behavior by atemon
in thread print behavior by Anonymous Monk

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.