in reply to Re: tied, or modified?
in thread tied, or modified?

Hmm, Perl 5.8.9 gives me

$ perl -MO=Deparse -e 'tied sub {}->()' tied {sub { } }->(); -e syntax OK
which gives a different error:
$ perl -e 'tied { sub {} }->()' Not a subroutine reference at -e line 1.

The code you mention doesn't compile:

$ perl -e 'tied { sub {}->() }' Can't modify anonymous hash ({}) in tied at -e line 1, at EOF Execution of -e aborted due to compilation errors.

Thanks for taking the time to think about this. I've cut and pasted these straight from the command line to avoid further incidents. :-)

Replies are listed 'Best First'.
Re^3: tied, or modified?
by ikegami (Patriarch) on Nov 13, 2009 at 23:40 UTC

    which gives a different error:

    As it should. Like I said, it's a bug in Deparse.

    An anonymous hash is the anonhash opcode.

    $ perl -MO=Concise,-exec -e'{}' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <0> pushmark s 4 <@> anonhash vK* 5 <@> leave[1 ref] vKP/REFC -e syntax OK

    Note the lack of anonhash in the code that's actually produced by tied sub {}->().

    $ perl -MO=Concise,-exec -e'tied sub {}->()' 1 <0> enter 2 <;> nextstate(main 2 -e:1) v:{ 3 <0> pushmark s 4 <0> pushmark sRM 5 <$> anoncode[CV ] lRM 6 <1> refgen sK/1 7 <1> rv2cv sK/NO() 8 <1> entersub[t2] sKRMS/NO(),TARG,1 9 <1> tied vK/1 a <@> leave[1 ref] vKP/REFC -e syntax OK

    Deparse is wrong to add an anon hash constructor. Therefore, trying to execute the output of Deparse makes no sense.