Mike Blezien wrote:
Hello,
I'm working on settup a hash something like this:
my $catid = 'A'; my(%conf);
$conf{cat} = { A => ( ["15.00","Three months(90days)","90"], ["30.00","Six months(180 days)","180"], ["45.00","Nine months(270 days)","270"], ["60.00","Twelve months(365 days)","365"] ), B => ( ["20.00","Three months(90days)","90"], ["40.00","Six months(180 days)","180"], ["50.00","Nine months(270 days)","270"], ["70.00","Twelve months(365 days)","365"] ) };
print header();
for (my $i=0; $i<@{$conf{cat}->{$catid}}; $i++) { print qq~CatPrice: $conf{cat}->{$catid}[0] CatDays: $conf{cat}->{$catid}[2]<BR>~; }
But all I'm getting is the first element array in key 'A'
"15.00 90" instead of all 4 array in the key in the loop... what I'm I doing wrong, or is there away doing this better ??
Your data is not structured as you may think it is. Try printing it out with Data::Dumper.
use Data::Dumper; warn Dumper( \%conf ), "\n";
More specifically, elements of a hash or array must be a scalar not a list. Hash elements 'A' & 'B' in your code above cannot be a list of array references, they should probably be array references:
$conf{cat} = { A => [ ... ], B => [ ... ], };
thanks Randy, I see the problem, but need to come up with a better way of doing this then.
Thx's
-- Mike(mickalo)Blezien =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing Providing Internet Solutions that work! =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>