On Oct 17, James Edward Gray II said:
>sub new {
> my $class = shift;
> $class = ref $class if ref $class;
> my %args = @_;
> my $self = bless { }, $class;
>
> # needs hierarchical initialization here
>
> $self->initialize(%args);
> return $self;
>}
>This is good, I just give everything an initialize() method. The
>problem is that I have to remember to call the parents initialize().
>Is there a way to get a hold of the referent's @ISA array, where my
>comment is above, and perform the needed initializations so my objects
>don't have to?
Sure:
{
no strict 'refs'; # sorry, but it's a bit more convenient this way
for (@{ "${class}::ISA" }) {
$self->initialize(%args);
}
}
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]