Help for this page

Select Code to Download


  1. or download this
    $hash{$key}= 'ape:b:cat' #stores the values 'ape','b' and 'cat' into t
    +he hash using ':' as delimiter
    #simple but the delimiter better not be in any values (you would have 
    +to escape the delimiter which is messy)
    ...
    }
    
    $hash{$key}.= ':' . $anothervalue; #add another value (but if the hash
    + value was empty you have just added two values, an empty string and 
    +$anothervalue. This is another disadvantage)
    
  2. or download this
    $hash{$key}= ['ape','b','cat']; #stores the values 'ape','b' and 'cat'
    + into the hash
    
    ...
    $value= $hash{$key}[2]; #get the third value, short form
    
    push @{$hash{$key}}, $anothervalue; #add a value