Trina Espinoza wrote: > > Can you have a multidimentional hash that has both two and three keys? > > For example: > > Array with two keys and a value: > $HASH-> {$VAR}{letter} ="a"; > > Same Array with three keys and a value: > $HASH->{$VAR}{$number){float} = "1.1";
That closing ')' should be a '}'. > $HASH->{$VAR} {$number}{integer}="2"; > > Is this possible? I'm not sure if it didn't wok b/c of an error in syntax or > if it's because it's not possible. Yes, it's certainly possible. What error did you get? > > To print the two keys and value I know I do: > > print $HASH->{$VAR}{letter}; > > BUT, if I have three keys and a value, how do I print it? If $number is a > different number every time (1 ..10), how do I get it to print so that it > iterates through each number and gives me the float and the integer for > each. Something like this, below? use strict; use warnings; my $HASH = {}; my $VAR = 'key'; my $number = 99; $HASH->{$VAR}{letter} = "a"; $HASH->{$VAR}{$number}{float} = "1.1"; $HASH->{$VAR}{$number}{integer} = "2"; my $hash = $HASH->{$VAR}; foreach my $key (keys %$hash) { my $value = $hash->{$key}; if ($key eq 'letter') { printf "%s => letter %s\n", $key, $value; } else { # $key is a hash reference printf "number %s => float %s, integer %s\n", $key, $value->{float}, $value->{integer}; } } **OUTPUT letter => letter a number 99 => float 1.1, integer 2 > Hope this makes sense! Any examples would help get me started I'm not completely clear on your problem, but I hope this gets you going. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>