I have an odd, funky situation. I'm writing an aggregate object module, Request.pm, that contains, among others, a CGI object. My intent is to import some of CGI's methods (per CGI's docs) into my object and have access to them as though they were methods of Request. My problem is making the imported method stick beyond the scope of my _init() method. Here's a sample:
sub new
{ #object blessing stuff skipped here...
$self->_init(@_);
return $self;
}
sub _init
{ my $self = shift;
#the following creates the CGI object, importing the
#method param() into current scope, _init()
$self->{'query'} = new CGI qw(param);
#...etc...
}
After having done this, the user only needs to do...
my ($comment) = $requestobj->param('comment');
...to access the value of the form variable "comment". I've tried different methods to make this work, but nothing has seemed to work short of creating a stub method in Request to forward any parameters and return context to the CGI::param() method.
Is there a way, while in the scope of _init(), to assign the imported method param() to the Request object? Would I have to use, perhaps, a sub reference? Would I have to rely on AUTOLOAD to form a forward call to any imported methods? I know that when _init() goes out of scope, the methods imported from CGI fail to exist; I want these methods to be sticky.
I am a-thoroughly confused. Thanks for any help.
-Shawn / (Ph) Phaysis
If idle hands are the tools of the devil, are idol tools the hands of god?