in reply to Re: Module ( method ) alias ?
in thread Module ( method ) alias ?
ModB.pm
package ModB; use parent qw'ModA'; sub new { my $c = shift; return $c->SUPER::new ( @_ ) ; } 1;
ModA.pm
package ModA; sub new { return bless {}, shift } sub p { print @_ } 1;
main.pl
use ModB; my $b = ModB->new(); $b -> p ( "World!" ) ;
It prints ModB=HASH(0x182a5e4)World!. Don't know what am I missed. Also, could you explain a little what is SUPER:: referring to? Is it refer to where parent declared? And how can I inherit other methods with other method name?
Thanks again!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Module ( method ) alias ?
by Anonymous Monk on Oct 04, 2012 at 07:43 UTC | |
by exilepanda (Friar) on Oct 04, 2012 at 22:13 UTC |