There is now also Ref::Util which avoids the need to compare the result against a string (which itself might contain a typo). So, instead of
use Scalar::Util 'reftype';
if (reftype ($foo) eq 'ARAY') { # spot the typo
do_something ();
}
which would silently fail to do anything even if $foo were an arrayref, we can now say
use Ref::Util 'is_arrayref';
if (is_arrayref ($foo)) {
do_something ();
}
which would throw a compile-time error if we had a similar typo in the function name.
Ref::Util also uses the XS implementation (if installed) which makes it fast. It has no dependencies beyond Exporter. There are plenty of other goodies in this module which you can find in the documentation. |