On Thu, 17 Feb 2022 at 11:19, Yuki Kimoto <kimoto.yuki@gmail.com> wrote: > In order that the module author pass arguments safely, dual life module " > buildin.pm" and the function to pass arguments safely. > > # Pass arguments safely > package Foo; > > use builtin 'call_cb_safe'; > > sub execute { > my ($cb) = @_; > > # Pass arguments safely > call_cb_safe($cb, (1, 2)); > } > Yes, but this has been covered several times on the list recently. See https://metacpan.org/pod/Acme::Signature::Arity#coderef_ignoring_extra for this specific case - I think your example would look like this: package Foo; use Acme::Signature::Arity qw(coderef_ignoring_extra); sub execute { my ($cb) = @_; # Pass arguments safely coderef_ignoring_extra($cb)->(1, 2); } (or use `min_arity`/`max_arity` to apply different rules)Thread Previous | Thread Next