geektron has asked for the wisdom of the Perl Monks concerning the following question:
now, problem is, i can't get the superclass *data*. in the subcalss, $self->cgi is always undef, and i know that's because the subclass is calling the superclass *method* but not finding the CGI object in itself ( because it's superclass data ). i've tried caller to make sure the calling package isn't the superclass ( obviously ).package Handler; use strict; use CGI; sub new { my $self = shift; return bless { _cgi => CGI->new() }, $self; } sub cgi { my $self = shift; my $caller = caller(); return ( $caller eq 'Handler' ? $self->{_cgi} : $self->SUPER::->{_c +gi} ); } package HandlerMethods; use strict; use base qw/ Handler /; sub doSomething { my $self = shift; my $page = $self->cgi->param('foo'); return 1; }
i know the syntax *should* be easy, but i'm missing it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: accessing superclass data
by derby (Abbot) on Jul 30, 2003 at 19:39 UTC | |
by geektron (Curate) on Jul 30, 2003 at 19:53 UTC | |
by chromatic (Archbishop) on Jul 30, 2003 at 22:30 UTC | |
by geektron (Curate) on Jul 31, 2003 at 03:38 UTC | |
|
Re: accessing superclass data
by blokhead (Monsignor) on Jul 31, 2003 at 04:48 UTC | |
by geektron (Curate) on Jul 31, 2003 at 06:30 UTC |