use feature 'state'; use Type::Params2; use Types::Standard -types; sub function_with_positional_parameters { state $check = signature( pos => [ ArrayRef, Int, Int ], ); my ( $list, $start, $end ) = $check->( @_ ); my @slice = @{$list}[ $start .. $end ]; return \@slice; } sub function_with_named_parameters { state $check = signature( named => [ list => ArrayRef, start => Int, end => Int ], ); my ( $arg ) = $check->( @_ ); my @slice = @{$arg->list}[ $arg->start .. $arg->end ]; return \@slice; }