in reply to why does this subclassing not work?
You could try:
which does pretty much what you wanted to do by overriding a method -- but by redefining the subroutine...use Perl::Critic::Command ; use strict ; use warnings ; { package Perl::Critic::Command ; sub _render_policy_docs { my (%opts) = @_; my $pattern = delete $opts{-doc}; require Perl::Critic; my $critic = Perl::Critic->new(%opts); _set_up_pager($critic->config()->pager()); require Perl::Critic::PolicyFactory; my @site_policies = Perl::Critic::PolicyFactory->site_policy_na +mes(); my @matching_policies = grep { $_ =~ m/$pattern/ixms } @site_po +licies; exec 'annopod', $matching_policies[0] or die "exec annopod faile +d: $!\n"; } ; } ; unshift @ARGV, '--doc'; Perl::Critic::Command->run();
With use warnings you'll see it warn you about the redefinition. Of course, if the author changes the _render_policy_docs subroutine you're in a different sort of trouble... so: use at your own risk !
|
---|