in reply to Hash assignment misunderstanding
Is this creating pairs such as key_i => [value_i] foreach key and value elements?Yes. It uses a hash slice. It is a way of adding too/overwriting the initial keys/values using another hash. It may be easier to see an example:
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $default = { one => 1, two => 2, three => 3, }; my $config = { one => 100, two => 200, }; @$default{ keys %$config } = values %$config; print Dumper $default; __DATA__ output: $VAR1 = { 'three' => 3, 'one' => 100, 'two' => 200 };
update: added a link to the docs
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash assignment misunderstanding
by Anonymous Monk on Sep 06, 2006 at 09:39 UTC | |
|
Re^2: Hash assignment misunderstanding
by nevyn (Monk) on Sep 06, 2006 at 16:14 UTC | |
by hardburn (Abbot) on Sep 06, 2006 at 16:35 UTC | |
by wfsp (Abbot) on Sep 06, 2006 at 16:43 UTC |