sub foo { my $self = shift; # Is there a variable at all ( even undef ) my $anything = @_ ? shift : return undef; # Is there a defined argument my $def = defined $_[0] ? shift : return undef; # Is there a true argument my $true = $_[0] ? shift : return undef; # Is there an argument which conforms to a regex? my $re_ok = $_[0] =~ /^\w+$/ ? shift : return undef; # If the argument one of a limited number of values my $option = $_[0] =~ /^(?:this|that|foo|bar)$/ ? shift : return undef; # Is it a reference my $ref = ref $_[0] ? shift : return undef;