Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: Module ( method ) alias ?

by exilepanda (Pilgrim)
on Oct 04, 2012 at 07:04 UTC ( #997194=note: print w/replies, xml ) Need Help??

in reply to Re: Module ( method ) alias ?
in thread Module ( method ) alias ?

Thanks for answering. However seems work out a bit weird..

package ModB; use parent qw'ModA'; sub new { my $c = shift; return $c->SUPER::new ( @_ ) ; } 1;

package ModA; sub new { return bless {}, shift } sub p { print @_ } 1;

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
    The first two lines do it all, all the others are only if you want to change something , like swap AudioType with VideoType ), Modern Perl and perlootut explain everything else, just use Ctrl+F to search
      Haha! yes, I got it now. And the problem of my sub p was that I forgot to shift the class ref, so it prints the ref address. Thanks again!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997194]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2018-03-19 02:07 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.