if (ref $val eq "HASH") { ... } #### use Scalar::Does; if (does $val, "HASH") { ... }