in reply to Hash merging!

$A = \%a; creates a reference to the hash %a. References are akin to c pointers, but I'd recommend the tutorials and super search for more.

@$A{keys %b} = values %b; sets the list of (keys %b) equal to the list of (values %b) as hash elements of $A, which is a reference to %a.

You may also be interested in the PLEAC - Merging Hashes codes.

HTH

Replies are listed 'Best First'.
Re^2: Hash merging!
by jerry.hone (Initiate) on Apr 26, 2005 at 08:20 UTC
    Need to explain myself more...
    I understand pointers. It's the semantics of the @$A... line that's baffling me.
    I know values %b is returning and array
    Also keys %b is returning an array
    $A{array} doesn't seem to make sense and what exactly is the @ doing on the front.

      my %hash; # the % sigil denotes a hash $hash{'element'} = 1; # the $ sigil denotes a scalar value (the 'eleme +nt' element of %hash)

      Similarly, the @ sigil in @$A{keys %b} denotes list context. I believe it interpolates as (verified):

      @$A{(c,d,f)} = (9, 16, 36);

      Which is essentially the same thing as:

      $A{c} = 9; $A{d} = 16; $A{f} = 36;

      Given that $A = \%a, you could skip the reference:

      $a{c} = 9; $a{d} = 16; $a{f} = 36;

      @varname{LIST} is a hash slice, a list of all the values of %varname for the keys in LIST.