I use Perl::Critic and like it, but one thing I do not agree with is that it uses perldoc hardcoded as POD renderer. That's nothing worth to contribute a patch for, it just complicates everything for very little public gain. So I went into the sources (first the perlcritic program, and in recent releases, Perl::Critic::Command) and edited it to use annopod instead, just for myself.

Now I got fed up that every new release overwrites my local changes again, so I just spent some time to do it the proper way, like I should have done in the first place, changing behaviour through polymorphism. Behold pcpod! Instead of writing perlcritic --doc $POLICY_NAME I write pcpod $POLICY_NAME.

#!/usr/bin/env perl package Perl::Critic::Command::RenderPolicyDocsAnnopod; use parent 'Perl::Critic::Command'; sub _render_policy_docs { my (%opts) = @_; my $pattern = delete $opts{-doc}; require Perl::Critic; $critic = Perl::Critic->new(%opts); _set_up_pager($critic->config()->pager()); require Perl::Critic::PolicyFactory; my @site_policies = Perl::Critic::PolicyFactory->site_policy_name +s(); my @matching_policies = grep { $_ =~ m/$pattern/ixms } @site_poli +cies; exec 'annopod', $matching_policies[0] or die "exec annopod failed: + $!\n"; } unshift @ARGV, '--doc'; Perl::Critic::Command::RenderPolicyDocsAnnopod->run();

When I said »spent some time«, that was a lie. The code above really just took two minutes or so, but the last half hour I've been knee-deep in the debugger to find out why the stupid thing doesn't work, that is it still is the unoverridden behaviour. Aaaaargh! Relevant excerpt is below. Would the kind monks please deliver explanation and advice?

> perl -d `which pcpod` CodeLayout::RequireUseUTF8 [...] DB<1> s Perl::Critic::Command::_dispatch_special_requests(.../lib/perl5/site_p +erl/5.10.0/Perl/Critic/Command.pm:139): 139: if ( $opts{-doc} ) { _render_policy_docs( %opt +s ) } #Exits DB<1> s Perl::Critic::Command::_render_policy_docs(.../lib/perl5/site_perl/5.1 +0.0/Perl/Critic/Command.pm:588): 588: my (%opts) = @_;

In reply to 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.