"Best practice" is a matter of opinion (see various threads here regarding PBP). That said, I suppose Ref::Util is the best bet.
#!/usr/bin/env perl use strict; use warnings; use Ref::Util 'is_arrayref'; my $item = { x => 'a', y => ['b', 'c'] }; for my $key (keys %$item) { if (is_arrayref $item->{$key}) { print "Value for $key is an arrayref\n"; } else { print "Value for $key is not an arrayref\n"; } }
In reply to Re: hashref with(out) arrays
by hippo
in thread hashref with(out) arrays
by bfdi533
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |