Re: lvalue hash slice

Dave Mitchell <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
On Tue, Sep 30, 2003 at 11:53:01PM +0300, Gaal Yahas wrote:
> On Tue, Sep 30, 2003 at 08:12:54PM -0000, I wrote:
> > Sadly, this doesn't work as an lvalue:
> > 
> >     @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);        # WRONG
> 
> And evidently it does! Oops! :)
> 
> Has this always worked? I coulda sworn I tried it in the past with no
> luck...

Since at least 5.003_22, and probably well before then:

$ perl5.3.22 -e '@h{"a","b"} = (1,2); print @h{"a","b"}, "\n";'
12

(I tried it on Perl 1.0.15, but unfortunately it didn't like it.
I even managed to get it to coredump. Perhaps I should submit a bug
report?
:-)

-- 
"Strange women lying in ponds distributing swords is no basis for a system
of government. Supreme executive power derives from a mandate from the
masses, not from some farcical aquatic ceremony."
Dennis - Monty Python and the Holy Grail.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.