in reply to Re^2: Spliting a delimited string into variables
in thread Spliting a delimited string into variables
Initializing a hash can be done with an array, each pair of values in the array form key and value of the hash. Often '=>' is used as an alias to ',' to make this obvious:
my %hash= (0, 'ticket', 1 => 'dateadded');
{$names{$_}} on the other hand is not a really useful expression in perl, %{$names{$_}} refers to a hash whose reference is stored as value in another hash (i.e %names). A multidimensional hash or HashOfHashes in perlspeak
If what you wanted was a Hash of Hashes, the syntax looks like this:
$names{$_}{key}= 'value'; #or to initialize with an array: %{$names{$_}} = ('key1' => 'value1','key2' => 'value2');
if you want further information about HoH (Hash of Hashes), you might want to read perldsc and perllol
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Spliting a delimited string into variables
by pissflaps (Initiate) on Apr 08, 2011 at 21:23 UTC | |
by jethro (Monsignor) on Apr 11, 2011 at 08:55 UTC |