MSOL has asked for the wisdom of the Perl Monks concerning the following question:
I am creating the Values array from a file and i have the ID in values[0] I am checking if that ID is exists in the Hash that I created. if it's exists I copy the Values2 to my AOH. The Code is working fine. But I have a proplem that if I have ID that occured twice or more, it would only print for one of them. I would like change my code, so that it can also copy the ID for the other even if i have more the one.
Here is my current output:
| 60 | 811 |
| 50 | 813 |
| 820 | |
| 34 | 820 |
| 821 | |
| 32 | 821 |
| 60 | 811 |
| 50 | 813 |
| 34 | 820 |
| 34 | 820 |
| 32 | 821 |
| 32 | 821 |
if ( $intcounter > 0 )
{
if ( exists( $Hash{ $values[0] } ) )
{
$intrec = $Hash{ $values[0] };
$AoH[$intrec]{'Data'} = $values[1];
}
else
{
#print "ID can't be found in the data file\n";
}
}
$intcounter++- Comment on ID exists in Hash -I need to copy the value even if it exists more than one
- Select or Download Code
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ID exists in Hash -I need to copy the value even if it exists more than one
by Laurent_R (Canon) on Mar 01, 2014 at 11:05 UTC | |
|
Re: ID exists in Hash -I need to copy the value even if it exists more than one
by kcott (Archbishop) on Mar 01, 2014 at 20:34 UTC | |
by MSOL (Initiate) on Mar 02, 2014 at 21:51 UTC | |
|
Re: ID exists in Hash -I need to copy the value even if it exists more than one
by Anonymous Monk on Mar 01, 2014 at 09:21 UTC |