in reply to Re^5: Creating dynamic parent/child relationships
in thread Creating dynamic parent/child relationships

Consider passing what you call "the parent" around to each object that implements an action? So far you've been somewhat unclear about what you actually need, so it is somewhat hard to come up with good names for the parts that make sense in your context.

Maybe using "configuration" as name for what you call "parent" and "action" as name for what you call "child" would help?

my $cfg = My::Config->new_from_file('nysus.yml'); $cfg->process( $myfile ); package My::Config; use Module::Pluggable require => '1', sub_name => 'actions', instantiate => 'new', ; sub My::Config::process( $self, $filename ) { for my $action ($self->actions) { $action->operate( $self, $filename ); }; };

I don't think that passing data around in $self should be an overarching design principle.

Most of the code above is from Module::Pluggable, which still feels very applicable from what you've described so far and from the problems you encounter.

Maybe if you can elaborate more on the concrete problem you're trying to solve and the problems you encounter, we can give you more concrete advice?

Replies are listed 'Best First'.
Re^7: Creating dynamic parent/child relationships
by nysus (Parson) on Sep 04, 2019 at 14:36 UTC

    Basically, to get a better familiarity with OO Perl, I'm cutting my teeth and trying to get better at native OO by writing a potential CPAN module (if I can get it to good enough quality), which you can see here: https://github.com/sdondley/File-Collector. The synopsis should have the needed details.

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