Did you try enumerating the keys of %hash?

foreach my $outerKey(sort keys %hash){
   print "$outerKey\n";
   foreach my $innerKey(sort keys %{$hash{$outerKey}}){
      print "\t$innerKey\n";
   }
}






-----Original Message-----
From: Peter Rabbitson [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 14, 2005 5:21 PM
To: beginners@perl.org
Subject: Reference name

[Tim Johnson] <snip>

my %hash = ( 
        abcd => {
                a1 => 1,
                a2 => 2,
                a3 => 3
        }
);


How can I access the name (abcd) of the passed reference inside of the 
subroutine (not just the data a1 a2 etc but the actual key name)?
Currently 
what I am doing is passing 'abcd' as a second value to the subroutine,
but there 
got to be another way...? 
                        


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to