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

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top