Hash tables

G

Guillermo

I dont know how can I store and recover data to/from a hash table
which values are arrays.

Is it OK?

my %data = ();
my @attributes = ();
for($counter=1;$counter<@field;$counter++){
$attr = <DB>;
push(@attributes, $attr);
}

$data{$node} = @attributes;
$node = <DB>;
}

I cant recover the values stored in the hash table
 
G

Gunnar Hjalmarsson

Guillermo said:
I dont know how can I store and recover data to/from a hash table
which values are arrays.

perldoc perlreftut
perldoc perlref

I don't understand what the code you posted is supposed to do, but I
noticed that you tried to assign an array to a hash element:
$data{$node} = @attributes;

which can't be done. You need to assign a reference to the array:

$data{$node} = \@attributes;

Guess you have some reading to do.

Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,417
Messages
2,571,580
Members
48,797
Latest member
shadowoftheunknown

Latest Threads

Top