The most common are:
You get my point... it can be extended to cover most of the basics pretty well, and it probably much faster than calling to another subroutine.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 u +ndef; # Is it a reference my $ref = ref $_[0] ? shift : return undef;
In reply to Re: Re: validating function input
by adamk
in thread validating function input
by bobdeath
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |