in reply to Re: multiple array as hash value per key
in thread mutiple array as hash value per key

in case i have new set of data (new array) referring to same key,is it possible to push the array value to the hash? eg :
new set is read from a file while ($line <>){ ($key,$value)=split(/,/,$line); #suppose #line have 23,['g8',23,45] push @{$numbers{23}},$value; }
will this append the new array to existing key ?

Replies are listed 'Best First'.
Re^3: multiple array as hash value per key
by davorg (Chancellor) on Jul 02, 2009 at 07:36 UTC

    What you're looking for is probably more like:

    while (<>) { chomp; my ($key, @values) = split /,/, $_; push @{$numbers{$key}}, [ @values ]; }

    When playing with complex data structures, perldsc and Data::Dumper are your friend.

    --

    See the Copyright notice on my home node.

    Perl training courses