$ perl -e 'tied( sub {}->() )' Can't modify non-lvalue subroutine call at -e line 1.
My question is: Who's trying to modify anything?

If I were reading this, my reaction would be “You tie variables, not values, so it doesn't make sense to test the result of a subroutine call using tied” (I tried it in a fit of optimism anyway); but my question is not so much why this approach doesn't work as why I get an error about an attempted modification when none exists. Is tied doing something bizarre internally like trying to assign to its argument and seeing if a STORE method fires?

(On a presumably much simpler note, I don't see why

$ perl -e 'tied sub {}->()' Can't modify reference constructor in tied at -e line 1, near "})"
parses differently. According to perlop, -> is higher in priority than anything but terms and list operators. As near as I can tell from perlfunc, tied isn't a list operator. I don't know if it's a ‘term’ because I'm not really sure what a ‘term’ is. :-)

UPDATE: As tye pointed out in the Chatterbox, perl -e 'tied sub {}->()' doesn't actually produce that error. It was all a dream!)


In reply to tied, or modified? by JadeNB

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.