my $type_of_arg = ref $_[0]; if ($type_of_arg eq "ARRAY") { # Handle an array reference } elsif ($type_of_arg eq "") { # Handle an array } else { die "Unexpected reference type '$type_of_arg': $!"; }