Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^11: How to completely destroy class attributes with Test::Most?

by nysus (Parson)
on Aug 28, 2019 at 13:31 UTC ( [id://11105164]=note: print w/replies, xml ) Need Help??


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

I noodled around with this. So, the best I can tell, this makes iterating over files a two step process. First I have to create the iterator and then I have to loop over it? Something like this:

my $iterator = $fc->scan_blah_files; while ($iterator->next_file) { my $file = $iterator->selected_file; print $file . "\n"; } }

I rewrote it a bit to keep the get/next terminology:

sub AUTOLOAD { our $AUTOLOAD; my $s = shift; $AUTOLOAD =~ /.*::get(_next)*(_\w+)*_files*$/ or croak "No such method: $AUTOLOAD"; my ($next, $type) = ($1, $2); if ($next) { # create an iterat +or my $class = ref($s) . '::Iterator'; if (!$type) { return $class->new($s->get_files); # iterator for all + files } else { return $class->new(@{$s->{$type.'_files'}}); # iterator for fil +e subset } } else { return @{$s->{$type.'_files'}}; # return file subs +et } }

$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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 01:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found