use feature qw( state ); # enable the `state` feature from Perl 5.10+ use Types::Standard qw( Object Num ); use Type::Params qw( compile ); sub transfer_money { state $check = compile( Object, Object, Num ); my ($from_account, $to_account, $amount) = $check->(@_); ...; }