in reply to Perl hashes: is there some way of adding more data to the value associated with an existing key?

The value of a hash entry is a scalar, but this scalar can be a reference to an array, into which you can put more than one value:

push @{ $hash{$id} }, $val;

Also, Perl features autovivification, so you don't need to worry about the initial case when there is no array(ref) yet — i.e. Perl implicitly creates it for you.

  • Comment on Re: Perl hashes: is there some way of adding more data to the value associated with an existing key?
  • Download Code