in reply to Multiple Hash key values problem !!
The solution to this is actually quite simple. The values in a hash must be scalars. References are scalars. So use array references as the hash values.
Replace
$href{$1} = $2 if $_ =~ /(\S+)\s+(\S+)/;
with
push @{$href{$1}}, $2 if $_ =~ /(\S+)\s+(\S+)/;
You'll need a little more work to use the value data, but you haven't lost any of it.
while (my ($key, $value) = each(%href)) { print "$key, (@{$value})\n"; }
The rest of your code will need similar modifications to adapt to arrays of values.
|
|---|