in reply to Technique for building arguments from function name?
Although I agree with the other posts so far - the way the AM showed is how I might have done it (documented in Function Templates) - just in the spirit of TIMTOWTDI: Currying. For example:
sub myfunc { my $what = shift; print "<$what> (@_)\n"; } my $myfunc_dog = sub { myfunc("dog",@_) }; my $myfunc_cat = sub { myfunc("cat",@_) }; $myfunc_dog->("woof"); $myfunc_cat->("meow");
Although I do have to say that I find pretty much all of the solutions overkill... why not just myfunc("dog","woof")?
|
|---|