in reply to Proper way to call subclass methods?

The mention of @ISA indicates you wanted to use inheritance (which can be nowadays implemented easier with parent), but by wrapping an object in an attribute, you seem to use delegation instead (in a weird way).

With inheritance, there's no need to wrap the FFMech object in an EventRepository object - each EventRepository object already is a FFMech object, too.

The gets method seems to belong to EventRepository, not to FFMech: the nested _mech doesn't exist in the former class. With delegation, you'd define a get method in the FFMech class that would call $self->{_mech}->get, and in the EventRepository, you'd do the same: but its get would call FFMech's get, which in turn would call the original 'get'.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: Proper way to call subclass methods?
by nysus (Parson) on Mar 08, 2016 at 16:57 UTC

    I'm not sure I follow. I removed the EventRepository object out of the code just to try to simplify things:

    my $ffm = FFMech->new; $ffm->gets('http://nyt.com');

    This results in an error:

    Can't use an undefined value as a HASH reference at /usr/local/share/p +erl/5.20.2/WWW/Mechanize/Firefox.pm line 804.

    The gets() method in FFMech looks like this now:

    sub gets { my $self = shift; my ($url, $sec, $syn) = set_args(@_); $self->get($url); sleep($sec); }

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
    $nysus = $PM . $MCF;
    Click here if you love Perl Monks