|Perl: the Markov chain saw|
Re^2: a loop for creating subroutines?by mascip (Pilgrim)
|on Aug 27, 2012 at 19:58 UTC||Need Help??|
More solutions, cool :-)
I see that lanX's answer is the "good" clean answer, but i don't like it as a stand-alone answer, as the code then looks ugly (i forgot to say it's a method, not a function) :
(I used %S instead of %mysubs. And i use Moose, so i need to pass $self as an argument).
So, what i did was to use AUTOLOAD, to call these subroutines :
which enables me to call
Now, the question is : is that clean, and are there "cleaner" (and why) solutions.
I must say i'm not in love with the 'eval' solution ( but it works :-) ).
Would it be cleaner to do
But then i will also need to put $self as an argument all the time.
What about installing them in the import table : is it cleaner than using AUTOLOAD ?