in reply to Re: Experimenting with Lvalue Subs
in thread Experimenting with Lvalue Subs

Zaxo,
The body of an lvalue sub doesn't get executed when it is used as an lvalue.

Not sure if that was the original behavior back in 1999 when they were first introduced but newer versions certainly disagree with you:

my %foo; get_set( 'foo' ) = 42; print get_set( 'foo' ); sub get_set :lvalue { my $key = shift; print "key is $key\n"; my $junk; $key eq 'foo' ? $foo{$key} : $junk; } __END__ key is foo key is foo 42
...You can retrieve it with $foo->get_set($bad_key)

Where $bad_key is any and all bad keys. This is why one of the desired features would be to determine if it was in assignment or not.

Cheers - L~R

Replies are listed 'Best First'.
Re^3: Experimenting with Lvalue Subs
by Zaxo (Archbishop) on Jan 24, 2005 at 20:31 UTC

    Now _that_ is interesting. Anybody know when it was introduced?

    /me is off to experiment anew . . .

    After Compline,
    Zaxo