in reply to lvalue subs return undef, playing with experimental features, the End of the World, etc

Seems to work here, what version of perl are you using and how are you calling the sub? Here's a version abridged for the command line:

$ perl -Mstrict -we'{my %hsh;sub set:lvalue{$hsh{shift}}}my $baz=set(" +foo")="bar"; print $baz,$/,set("foo"),$/' bar bar $
This is Perl 5.6.1.

Update: Changing the oneliner to be more like yours, I get:

$ perl -Mstrict -we'{my %hsh;sub set:lvalue{$hsh{shift}}}my $baz=set(" +foo")=([qw/bar baz/]); print $baz,$/,defined set("foo"),$/' ARRAY(0x8106284) 1 $
which is what I'd expect. Recent AS should be fine.

U 2 : ++tadman for the solution, well spotted!

After Compline,
Zaxo

  • Comment on Re: lvalue subs return undef, playing with experimental features, the End of the World, etc
  • Select or Download Code

Replies are listed 'Best First'.
Re: Re: lvalue subs return undef, playing with experimental features, the End of the World, etc
by erikharrison (Deacon) on May 07, 2002 at 06:08 UTC

    Most recent Active State build on Windows 98.

    I'm running the code exactly as it is in the node - it is called in the last two lines.

    Indeed, your oneliner version runs fine (though I though that the $hsh{shift} needed to be $hsh{+shift}. What am I missing?)

    Cheers,
    Erik