You've already gotten lots of good explanations and answers. In your case, graff's node sounds like the best answer.
I just want to offer another suggestion for the general case.
What is the proper syntax for passing arguments to a subroutine that has a named reference when using callbacks?
You can use closures, as dank suggested; but you can do it without copying the whole subroutine body and you can make it general.
sub callback { my $coderef = shift; my @args = @_; sub { $coderef->(@args) } }
That will allow you to write things like
but will work with any coderef (named or not) and arguments.-command => callback($change_mode, 3),
-sauoq "My two cents aren't worth a dime.";
In reply to Re: Passing arguments to callback routines with named references
by sauoq
in thread Passing arguments to callback routines with named references
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |