Re: lvalue hash slice

Uri Guttman <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
>>>>> "GY" == Gaal Yahas <[email protected]> writes:

  GY> I like hash slices:
  GY>     ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ };

  GY> Sadly, this doesn't work as an lvalue:

  GY>     @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);        # WRONG

works fine for me.

perl -le '@h{ qw/aaa bbb/ }= (3, 5);print join ",", values %h'
5,3

where did you get the notion that hash slices won't work as an lvalue?
any list (of lvalues) can be an lvalue and a slice is just syntactic
sugar for the same list expanded out.

uri

-- 
Uri Guttman  ------  [email protected]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class
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.