You could try:

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();
which does pretty much what you wanted to do by overriding a method -- but by redefining the subroutine...

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 !


In reply to Re: why does this subclassing not work? by gone2015
in thread why does this subclassing not work? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.