You are overwriting the hash each time round the loop. This removes all data in the hash and replaces it with the new values.
It sounds like you want to add data to the hash on each iteration. In that case you just need to assign to the individual key.
foreach my $id ($doc->getElementsByTagName('attack')) { $_attack{$id} = { 'severity' => '0', 'category' => '1', }; }
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In reply to Re: unable to store keys and values in hash when "keys" are passed at runtime
by davorg
in thread unable to store keys and values in hash when "keys" are passed at runtime
by phemal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |