in reply to function input may be hash ref

if (ref $val eq "HASH") { ... }

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") { ... }
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name