Tomas Doran pisze:
> Paweł Tęcza wrote:
>> Thank you very much for your response! Is it a way to autogenerate all
>> necessary subroutines in a loop or I need define all of them manually?
>> They should have very similar body :)
>
> Here is the gross method:
>
> no strict 'refs';
> foreach my $name (qw/ method_one method_two /) {
>      *{$name} = sub {
>          my $self = shift;
>          # Your code here
>      };
> }
>
>
> I'd instead recommend using Moose to do it for you:
>
> use Moose;
> foreach my $name (qw/ method_one method_two /) {
>      __PACKAGE__->meta->add_method($name, sub {
>          my $self = shift;
>          # Your code here
>      };
> }
>
> This is (a) less icky, and (b) means that your generated code will come
> out nicely in stack traces / error reports, rather than being 'ANON'.

Hi Tom,

Perl is great! Thanks a lot for these methods! It's very helpful for me.
I'm your debtor now ;)

My best regards,

P.


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to