On Nov 20, 6:22 am, [EMAIL PROTECTED] (Frank Bergemann) wrote:
>         foreach my $ref (\%Hash1, \%Hash2, \%Hash3) {
>                 while(my ($key, $value) = each(%$ref)) {
>                         debug ("$key -> $value")
>                 }
>         }
>
> I'd like to prefix the name of the hash for the elements in my
> debug(...).
> How to get the name of what $ref is actually pointing at currenty
> (%Hash1, Hash2, Hash3)?

In general, you don't.   Obvious workaround - use a hash:

my %hash_named = (hash1 => \%Hash1, hash2 => \%Hash2, hash3 => \
%Hash3);
while (my ($name, $ref) = each %hash_named) {
   while (my ($key, $val) = each %{$ref}) {
      debug("$name: $key => $val");
   }
}

Paul Lalli


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


Reply via email to