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
    Thank you very much for your help
Re^2: Hash assignment misunderstanding
by nevyn (Monk) on Sep 06, 2006 at 16:14 UTC
    I would also be very suspicious of relying on keys and values having the same order, they probably will (might even be guaranteed) but I'd still prefer not to have an unsorted keys call as a hash slice. Instead of:
    @$default{ keys %$config } = values %$config;
    ...I'd probably write:
    my @ids = keys %$config; @$default{ @ids } = @$config{ @ids };
    ...this is also less likely to get updated to be "bad".
    --
    And-httpd, $2,000 security guarantee
    James Antill

      keys() and values() are guarenteed to be the same as long as you don't modify the hash in between calls.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      From the docs:

      The keys are returned in an apparently random order, but it is the same order as either the values() or each() function produces (given that the hash has not been modified).