in reply to Re^19: How to completely destroy class attributes with Test::Most?
in thread How to completely destroy class attributes with Test::Most?

Nice, I got the File::Collector subclass down to one sub and just a few lines of code now:

package File::Collector::DateClassifier ; use strict; use warnings; use Log::Log4perl::Shortcuts qw(:all); use File::Collector::DateClassifier::Iterator; use parent qw ( File::Collector ); sub _classify_files { my ($s, $files_added) = @_; $s->add_iterators( qw ( some_files other_files ) ); foreach my $file (sort @$files_added) { $s->add_to_iterator('some_files', $file); } } return 1;

This feels fun, now. I feel like I can call myself an intermediate Perl programmer now. Only took 20 years. :)

Thanks again for all your time advising me on this. I learned a lot. I'll post this up to CPAN when I think it's CPAN worthy. I got it on a git for now: File::Collector

$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

  • Comment on Re^20: How to completely destroy class attributes with Test::Most?
  • Download Code

Replies are listed 'Best First'.
Re^21: How to completely destroy class attributes with Test::Most?
by jcb (Parson) on Aug 30, 2019 at 23:59 UTC

    Nice, but I think you could eliminate lines 4 and 5 also, if you keep the corresponding ::Iterator subclass in the same file, and I do not see any log4perl calls here.

    And the convention for the final true value is a simple 1;, with no need for the return keyword.

    And you are very welcome. There are still some rough edges (as I mentioned in the other reply) and I will say to make sure to write good tests. I have found Devel::Cover useful in my own work, but be careful that you do not end up "testing to the implementation".