Consider this:

perl -MO=Deparse,-p print $x= "hi"; chomp $x= "hi"; chop $x= "hi"; sprintf $x= "hi"; printf $x= "hi"; reverse $x= "hi"; join $x= "hi"; unlink $x= "hi"; die $x= "hi"; warn $x= "hi"; __END__ print(($x = 'hi')); (chomp($x) = 'hi'); (chop($x) = 'hi'); sprintf(($x = 'hi')); printf(($x = 'hi')); reverse(($x = 'hi')); join(($x = 'hi')); unlink(($x = 'hi')); die(($x = 'hi')); warn(($x = 'hi'));
Note how chomp and chop are the only ones that get parsed the way they do.

Quoting bits of perlman:perlop:

left terms and list operators (leftward) [...] right = += -= *= etc. [...] nonassoc list operators (rightward) [...] =head2 Terms and List Operators (Leftward) [...]
If any list operator (print(), etc.) or any unary operator (chdir(), etc.) is followed by a left parenthesis as the next token, the operator and arguments within parentheses are taken to be of highest precedence, just like a normal function call.
[...] =head2 List Operators (Rightward)
On the right side of a list operator, it has very low precedence,

So that means that list operators w/o parens around their arguments should bind less tightly than assignment operators. This is the case for all of the list operators I used in my sample code except for chop and chomp. I can't find anything special about those two core functions that would explain their special treatment.

This is made worse by the fact that chomp( @x )= whatever; doesn't generate an error like all of these do:

chop( $x )= whatever; chop( @x )= whatever; chomp( $x )= whatever;
(I've already reported this last bug to p5p.) such that chomp my @input= <STDIN>; does nothing useful but reports no errors nor warnings (well, it declares @input and leaves it empty and then reads one line from STDIN and throws it away, most of which isn't useful).

        - tye (but my friends call me "Tye")

In reply to chop/chomp bind too tightly by tye

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.