On Tuesday 29 June 2004 08:49, Daniel Falkenberg wrote: > Hello All, Hi Dan,
> I currently have a hash of a hash... > > > %HoH = ( > > Key1 => { > > Apple => "Green", > > Banna => "Yellow", > > }, > > Key2 => { > > Carrot => "Orange", > > Tomoatoe => "Red", > > }, > > ); > > How can I assign Key2 to a variable? # If you want to assign Key2's value, you could so something like: my $key2_ref = $HoH{Key2}; print "key2_ref : $key2_ref\n"; # Note that $key2_ref contains a hash-ref now, so if you want to use it as a # hash, you should tell perl that you want to use it as an hash: my %key2_hash = %{$key2_ref}; print "key2->carrot : " . $key2_hash{Carrot} . "\n"; # You can use the same technique to access the inner hashes: my $carrot_color = ${$HoH{Key2}}{Carrot}; print "carrot color : $carrot_color\n"; # Theres another version of accessing a value of a hash ref # that more pleasant to the eye: my $carrot_color2 = $HoH{Key2}->{Carrot}; print "carrot color 2 : $carrot_color2\n"; Take a look at perldoc perlreftut It's a very good (and short) tutorial about references that explains all this much better than I can. HTH, Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>