in reply to Creating data structure from multiple pairs of information

Assuming your're not going to have repeats of dog types, you could arrange your hash as :

%dog_hash (
"Beagle" => "Type 3",
"Retriever" => "table scraps"
);

Jack

  • Comment on Re: Creating data structure from multiple pairs of information

Replies are listed 'Best First'.
Re^2: Creating data structure from multiple pairs of information
by Grundle (Scribe) on Feb 17, 2005 at 19:37 UTC
    Why does it matter if your dog repeats?
    if($dog_hash{$dog_type}){ print "dog [$dog_type] already in hash\n"; }else{ $dog_hash{$dog_type} = $food_type; }
    I think that RazorbladeBidet's referral is probably the way to go if you really want to know how to hash well.
      or

      push @{$dog{$dog_type}}, $food_type;

      if more than one food type is possible.
      (That is, a hash of array references)
      --------------
      It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs