in reply to scalar variable or array reference test

The easiest way I can think of is
if (ref $var eq 'SCALAR') { print "scalar\n"; } elsif (ref $var eq 'ARRAY') { print "array\n"; } elsif (ref $var eq 'HASH') { print "hash\n"; }
hth.