sub foo { my $array_ref=shift; ref($array_ref) ne "ARRAY" and die "Can't use anything but an array"; ... }