Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: why does this subclassing not work?

by gone2015 (Deacon)
on Apr 10, 2009 at 14:35 UTC ( [id://756841] : note . print w/replies, xml ) Need Help??


in reply to why does this subclassing not work?

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 !