if ( ! ref($x) ) { # Not a reference } elsif ( UNIVERSAL::isa($x,'HASH') ) { # Reference to a hash } elsif ( UNIVERSAL::isa($x,'ARRAY') ) { # Reference to an array } elseif ( UNIVERSAL::isa($x,'SCALAR') || UNIVERSAL::isa($x,'REF') ) { # Reference to a scalar } elsif ( UNIVERSAL::isa($x,'CODE') ) { # Reference to a subroutine }