foreach my $key (keys %hash) { $value = $hash{$key}; # Perhaps a dispatch table for this would be better... if (ref($value) eq q{ARRAY}) { # Do whatever you you feel like doing with your array } elsif (ref($value) eq q{}) { # Scalar, handle as you wish } else { # None of the above types; make sure you know } }