Re: lvalue hash slice

Jayaprakash Rudraraju <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <Pine.GSO.4.50.0309301601230.12296-100000@shellfish.ece.arizona.edu>
1:32pm, IP packets from [email protected] delivered:

> On Tue, Sep 30, 2003 at 11:07:24PM +0300, Gaal Yahas wrote:
> > I like hash slices:
> >
> >     ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ };
> >
> > Sadly, this doesn't work as an lvalue:
> >
> >     @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);        # WRONG
>
> It doesn't?
>
> $ perl -wle '$one=1; $two=2; $three=3; @h{qw(a b c)} = ($one,$two,$three);  print %h'
> c3a1b2

You cannot print hash, like you can print a list. Because elements in the
hash are stored differently to optimize retrieval of hash elements.

>
>

--
Off the keyboard, over the bridge, past the hub, thru the router,
down the line, ....nothing but net!!
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.