in reply to function input may be hash ref
if (ref $val eq "HASH") { ... } [download]
or if you wish to also accept values that are "hashref-like" (e.g. blessed hashrefs, objects overloading %{}), then:
use Scalar::Does; if (does $val, "HASH") { ... } [download]