This was a change in how Perl parses things. The new rule is "if it looks like a function call, treat it as a function call" and it has to do with what to do when you have a an identifier followed by an open paren but with whitespace in between.

So the code: print ( $foo == 1 ) ? "hi" : "bye"; is now parsed as: print( $foo == 1 ) ? "hi" : "bye"; or, with an extra set of parens to make it clear: ( print( $foo == 1 ) ) ? "hi" : "bye";

It used to be that the first case was more ambiguous. Sorry, I don't recall the details. I think part of the original reason this was looked at was that "print (" was parsed differently than "print\n(", but I think there were other "interesting" cases. So this became one of the relatively few places where Perl chose consistancy over DWIM.

So you can "thwart" this case by putting some non-whitespace between the identifier ("print") and the open paren. The cases I showed of this were adding a "(" [and a matching ")"] or adding a "+". A long time ago uniary "-" was made to work with barewords (not just numbers), primarilly to support the argument passing syntax that came from Python tcl when Tk was ported to Perl: meth( -foo => "bar" ); The "-" is just prepended to the bareword giving use the result of meth( "-foo", "bar" ); for that code. Later, unary "+" was made to work with just about anything as a way to give Perl hints about how to parse things. In the case of unary "+", it is just dropped completely (it doesn't even impose a scalar context on its operand).

Update: Sorry for "blaming" the wrong language there at first.

        - tye (but my friends call me +Tye)

In reply to (tye)Re2: If / elses by tye
in thread If / elses by mbond

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.