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. }