in reply to Re: compare values within hash
in thread compare values within hash

That's one way to do it,But is it the best way? The values are already in the hash as arrays,Why should one store them again in separate ones?

Replies are listed 'Best First'.
Re^3: compare values within hash
by almut (Canon) on Nov 23, 2008 at 15:38 UTC
    my @a1 = @{$hash{key1}}; my @a2 = @{$hash{key2}};

    You can avoid the copying by using references:

    my $a1 = $hash{key1}; my $a2 = $hash{key2}; ... if ($a1->[$i] eq $a2->[$i]) {

    which is functionally the same as

    if ($hash{key1}->[$i] eq $hash{key2}->[$i]) {

    but less to type if you need to access the arrays ($a1/$a2) more than once...