sub ctest { _self(@_); #Eliminate any object that may be in the args my %opts = @_; unless(defined($opts{'code'}) && ref($opts{'code'}) eq 'CODEREF'){ return ERROR; } unless(defined($opts{'mod'})){ $opts{'mod'} = 0; } return sub { #Retun useage info if called without args return [$opts{'args'},$opts{'mod'}] if(!@_); $opts{'code'}->(@_); } } #Used as: my $coderef = ctest( args => 3, code => sub { return 1 if(int($_[0]) == $_[0]); return; } ); $coderef->(4.23);