use strict; use warnings; use Tk; my $mw = MainWindow->new (-title => 'Hello World'); my @arr=('first', 'second', 'third'); my %hash = (A => 100, B => 200, C => [@arr], D => \&hi, E => $mw); $hash{'A'}=100; $hash{'B'}=200; $hash{'C'}=[@arr]; for (sort keys %hash) { print "$_ => "; if (ref($hash{$_}) eq 'ARRAY') { print "Array: ", join(', ', @{ $hash{$_} }); } elsif (ref($hash{$_}) eq 'HASH') { # do something else print "Hash: ..."; } else { print "Scalar: $hash{$_}"; } print "\n"; } sub hi { print "hello World"; }