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

That code for using the bundle did not work but this did:

{ package File::Collector::Iterator::All; sub AUTOLOAD { our $AUTOLOAD; my $self = shift; my @method = split /::/, $AUTOLOAD; my $method = pop @method; $$self->$method(@_) while ($$self->next); } }

$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^14: How to completely destroy class attributes with Test::Most?
  • Download Code

Replies are listed 'Best First'.
Re^15: How to completely destroy class attributes with Test::Most?
by jcb (Parson) on Aug 29, 2019 at 22:53 UTC

    I see the problem, too: $AUTOLOAD gets the fully-qualified method name, which can be used, but a call with that name will not find inherited methods.

    If performance is an issue, you might want to benchmark that solution against:

    { package File::Collector::Iterator::All; sub AUTOLOAD { our $AUTOLOAD; my $self = shift; my $method = ($AUTOLOAD =~ m/::([^:]+)$/); $$self->$method(@_) while ($$self->next); } }

    I do not know enough to predict which should be faster.