Hi, Use the "ref" function, it returns the type (or false if not a reference). Assuming it's either a scalar or another hash do this:
foreach my $data (keys %hash) { if (not ref($hash{$data})) { print "\$hash{$data} --> $hash{$data}\n"; } else { foreach my $second (keys %{$hash{$data}}) { print "\$hash{$data}{$second} --> $second\n"; } } } Although you'd be better with a recursive solution, such as: sub print_hash_recursively { my %hash = %{ (shift) }; my $prefix = shift; foreach (sort keys %hash) { # Recurse deeper if nested hash if (ref($hash{$_}) =~ /^HASH/) { print_hash_recursively($hash{$_}, "$prefix\{$_\}"); } # Else print line else { print "$prefix\{$_\} = $hash{$_}\n"; } } } To use my subroutine call with parameters: print_hash_recursively(\%hash, "Hash"); You'll find it works nicely no matter how many hashes within hashes you have. Note that this task is really the domain of the "DataDumper" module (AFAIK that's the name of it). Jonathan Paton ________________________________________________________________ Nokia 5510 looks weird sounds great. Go to http://uk.promotions.yahoo.com/nokia/ discover and win it! The competition ends 16 th of December 2001. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]