in reply to Importing CGI methods into a subclass as a class method
Update: broquaint made the good point that this could also be put in some BEGIN block.
I personally don't like AUTOLOAD. It smacks too much of hidden black magic to me. :-)my @methods = qw( param foo bar ); sub _init { my $self = shift; { no strict 'refs'; unless (defined \&{__PACKAGE__."::$methods[0]"}) { foreach my $method (@methods) { *{__PACKAGE__."::$method"} = sub { my $self = shift; return undef unless UNIVERSAL::isa($self->query}, CGI); return $self->{query}->$method{@_); }; } } } # Rest of stuff here. }
------
We are the carpenters and bricklayers of the Information Age.
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Importing CGI methods into a subclass as a class method
by ihb (Deacon) on Feb 13, 2003 at 23:24 UTC |