in reply to Simple array checking?
my %hash = qw(foo bar baz quux); my $key = "baz"; my @array = qw(x y z); $hash{$key} = \@array; print "$key exists in %hash\n" if exists $hash{$key}; print "\@array has contents\n" if @array > 0; print "\$hash{\$key} is an array\n" if ref($hash{$key}) eq 'ARRAY'; print "\$hash{\$key} is an array with contents\n" if @{$hash{$key}} > 0; __output__ baz exists in %hash @array has contents $hash{$key} is an array $hash{$key} is an array with contents
broquaint
|
|---|