Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Hash tables

Reply
Thread Tools

Hash tables

 
 
Guillermo
Guest
Posts: n/a
 
      03-01-2004
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
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      03-01-2004
Guillermo wrote:
> 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!

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
How to get database metadata information (i.e. existing tables and columns in tables) Chris Brat Python 5 08-22-2006 05:25 PM
Tables within tables Otuatail HTML 7 08-02-2004 04:42 AM
Text after 2 tables actually appears between 2 tables ! Peter Bassett HTML 3 08-15-2003 06:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57