Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Hash of arrays

by grantm (Parson)
on Oct 27, 2002 at 19:09 UTC ( #208366=note: print w/replies, xml ) Need Help??

in reply to Hash of arrays

I think the bit you're missing is that a reference is a scalar. So instead of this:

while ( ($key, @value) = each %id_veritasHash){

You need this:

while ( ($key, $value) = each %id_veritasHash){

Then to loop through the items in the array that the scalar $value references, instead of this:

foreach $temp (@value){

You need this:

foreach $temp (@$value){

The final bit of the puzzle is that each of your references points to the same array (the output from your code shows the same hex value in the stringified reference). To create a different array each time through the loop, instead of this:

@data = split /\t/, $line;

You need this:

my @data = split /\t/, $line;

There are other ways to create new arrays, which you can read about in perlreftut.

Replies are listed 'Best First'.
Re: Re: Hash of arrays
by heezy (Monk) on Oct 27, 2002 at 20:13 UTC

    Both of the replies to my posting were fantastic thanks guys! Up voting all round!


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://208366]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2023-02-08 03:27 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (40 votes). Check out past polls.