sub foo { my $failed; ($failed = 1 and carp "First Parameter must be greater than zero") if $_[0] <= 0; ($failed = 1 and carp "Too many parameters") if scalar @_ > 3; die "Invalid parameters; cannot continue" if $failed; ... }