in reply to Why can't I call SUPER from user code?
Basicaly thats is because your user should never be making such a decision. ;)
On the other hand you have some redundant code in there. put your new decleration in BAR and then the other inherit it. Also if your new class doesn't want to over right the parent class then it can just leave that sub undefined.
#!/usr/bin/perl use strict; package BAR; sub bang { print "BANG!\n"; } sub new { my $class = shift; return bless {}, $class; } package FOO; use base qw( BAR ); sub bang { print "* please be quiet *\n" } package BAZ; use base qw( BAR ); sub bang { my $self = shift; $self->SUPER::bang(); } package BAH; use base qw( BAR ); package main; my $foo1 = FOO->new(); my $foo2 = BAZ->new(); my $foo3 = BAH->new(); $foo1->bang(); $foo2->bang(); $foo3->bang();
For future reference instead of saying "Why won't perl let my user code call SUPER, as in $foo3->SUPER::bang? " tell us what the error was.It will make life much easier.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why can't I call SUPER from user code?
by Anonymous Monk on Mar 30, 2006 at 23:41 UTC | |
by eric256 (Parson) on Mar 31, 2006 at 01:44 UTC |