in reply to Re^2: Perl Array of Hashes
in thread Perl Array of Hashes

Did you use warnings and use strict when you ran the code?

But that aside, you are doing some strange things:

my $k=0,$str=""; for(my $i=0; $i<4;$i+=1) { @entry=undef; for my $j (0..7) { $h{"BUCK_$j"} = $bucket[$k+$j]; push @entry,\%h; }

The loop above will add 8 identical references to %h to @entry.

$hash_table[$i] = { ENTRY => [@entry]}; $k+=8; } #end of for i for(my $i=0; $i<4;$i+=1) { print "ENTRY-0-BUCK-0::", $hash_table[$i]->{ENTRY}->{BUCK_0}, "\n";

You can't address $hash_table like that since it is an array of hash references containing just the key ENTRY (which is a warning sign) that has the value array reference containing hash references.

}

Did you try following the advice and tried Data::Dumper on, say, (updated) @hash_table?

Replies are listed 'Best First'.
Re^4: Perl Array of Hashes
by abhay180 (Sexton) on Jul 27, 2009 at 13:16 UTC
    Yes, By using Dumper,I was able to correctly construct the data-structure i needed. Thanks a lot for all ur help.
Re^4: Perl Array of Hashes
by abhay180 (Sexton) on Jul 28, 2009 at 12:03 UTC
    Yes, with Dumper, i am able to generate data-structure of my choice. Thanks a ton.