Thanks for the tip on creating a simpler iterator. I had just been re-reviewing Damian Conway's old OO Perl book and I had closures and class variables on the brain and so reached for the shiny new hammer I had just learned about.
My new sub is actually spread out over several classes with FileCollector as my base class:
package FileCollector ; sub new { my $class = shift; my $s = bless { _files => {}, _target_repo => '', _selected_file => '', _common_dir => ''}, $class; $s->add_resources(@_); return $s; } sub add_resources { my $s = shift; ... does stuff, basically like an init subroutine ... } package FileParser ; use parent qw ( FileCollector ); sub new { my $class = shift; return $class->SUPER::new(shift); } sub add_resources { my $s = shift; $s->SUPER::add_resources(@_); $s->{_nonparseable_files} = $s->{_nonparseable_files} || []; $s->{_parseable_files} = $s->{_parseable_files} || []; $s->_test_parsability; } package HeaderAnalyzer ; use parent qw ( FileParser ); sub new { my $class = shift; return $class->SUPER::new(shift); } sub add_resources { my $s = shift; $s->SUPER::add_resources(@_); $s->{_bad_header_files} = $s->{_bad_header_files} || []; $s->{_blank_header_files} = $s->{_blank_header_files} || []; $s->{_no_header_files} = $s->{_no_header_files} || []; $s->{_good_header_files} = $s->{_good_header_files} || []; $s->{_unrec_header_files} = $s->{_unrec_header_files} || []; $s->_analyze_headers; } ...MORE PACKAGES THAT BUILD THE CHILD-PARENT CLASS CHAIN FURTHER...
I'm not sure how orthodox this design pattern is with the chained SUPER calls like this but it works really well. I'm not sure if this complexity might be part of my problem. I'm just cutting my teeth on old school OO. Have mostly used Moose and Moo up until now.
$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
In reply to Re^2: How to completely destroy class attributes with Test::Most?
by nysus
in thread How to completely destroy class attributes with Test::Most?
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |