From: Chap Harrison <c...@pobox.com> > Let me break this expression down according to my current understanding. > > @{$hash{adams...@keys} = @values; > > parses as follows: > > adams : short for 'adams', a string literal, being used as a hash key > $hash{adams} : the value in the hash associated with 'adams', a scalar > (always), and a ref to a hash in this case > {$hash{adams}} : extra braces, used to force correct "binding" (?) > with surrounding context, I expect. > {$hash{adams...@keys} : the hashref is dereferenced, and a set of keys > (provided by an array) is looked up in the hash, resulting in a set of > values; or, more precisely, *aliases* of values. > @{$hash{adams...@keys} : an array of aliases of the hash values > associated with the keys supplied in @keys. > @{$hash{adams...@keys} = @values : behaves much like... > > ( $hash{adams}{a}, $hash{adams}{ar}, $hash{adams}{af}, $hash{adams} > {aw} ) = ( 1, 19, 13, 11 )
That's prettymuch it, except that it's not an array of aliases, but LIST of aliases. The difference is subtle, but important. See http://perldoc.perl.org/perlfaq4.html#What-is-the-difference- between-a-list-and-an-array%3f and http://www.perlmonks.org/?node_id=130861 And it doesn't really make sense to add only the {...@keys} without the @. You have to consider them both at the same time, because the sigil you use affects how is the @keys evaluated! See %hash = (a => 999, b => 888, c => 777, d => 666, 3 => 123456); @keys = ('a','b','c'); print $ha...@keys},"\n"; print @ha...@keys},"\n"; $href = \%hash; print ${$hre...@keys},"\n"; print @{$hre...@keys},"\n"; HTH, Jenda ===== je...@krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/