lvalue hash slice

Gaal Yahas <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
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

But this does:

    push @values, reverse @keys;
    $hash{ $values[$#values - $_] } = $values[$_] for 0 .. @values / 2 - 1;
    $#values /= 2;


-- 
Gaal Yahas <[email protected]>
http://gaal.livejournal.com/
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.