JadeNB has asked for the wisdom of the Perl Monks concerning the following question:
My question is: Who's trying to modify anything?$ perl -e 'tied( sub {}->() )' Can't modify non-lvalue subroutine call at -e line 1.
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
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!)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: tied, or modified?
by tswall (Monk) on Oct 22, 2009 at 20:01 UTC | |
by JadeNB (Chaplain) on Oct 22, 2009 at 21:20 UTC | |
by Anonymous Monk on Oct 23, 2009 at 03:33 UTC | |
by JadeNB (Chaplain) on Oct 23, 2009 at 15:02 UTC | |
|
Re: tied, or modified?
by ikegami (Patriarch) on Nov 10, 2009 at 18:23 UTC | |
|
Re: tied, or modified?
by ikegami (Patriarch) on Nov 13, 2009 at 23:34 UTC | |
by JadeNB (Chaplain) on Nov 13, 2009 at 23:37 UTC | |
by ikegami (Patriarch) on Nov 13, 2009 at 23:40 UTC |