Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: I'm in trouble with Perl's OO programming

by guha (Priest)
on Jun 09, 2005 at 09:16 UTC ( #465033=note: print w/ replies, xml ) Need Help??

in reply to I'm in trouble with Perl's OO programming

Inheritance does not work when you access WatchLog and SendEmail as subroutines. In fact for the sake of symmetry I would use a method invokation for AddLocalTime or at least change the name to _AddLocalTime to indicate that it is a local class method intended for use within the class.

use base A .... sub Schedule { my ($self) = @_; $self->addTab(_AddLocalTime); $self->addTab($self->WatchLog); $self->addTab($self->SendEmail); } sub _AddLocalTime { }

Comment on Re: I'm in trouble with Perl's OO programming
Download Code
Replies are listed 'Best First'.
Re^2: I'm in trouble with Perl's OO programming
by chromatic (Archbishop) on Jun 09, 2005 at 17:32 UTC

    That will actually call the methods at the point of definition, not in the loop. I think you meant instead:

    $self->addTab( sub { $self->WatchLog() } );

    Another option is to provide the name of methods to call:

    $self->addTab( 'WatchLog' );

    and then call them with:


    That's really late binding and it can be useful.

      You are right! I thoroughly misunderstood the OP.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://465033]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2015-11-30 11:03 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls