#!/usr/bin/env perl use warnings; use 5.012; use utf8; use WWW::Mechanize::Cached; use Some::Module qw(some_method); my $url = '...'; my $result = some_method( $url );
some_method()使用自己的get()形式LWP :: Simple.
我怎么能用这个脚本中的my_get()覆盖get()?
sub my_get { my $url; my $mech = WWW::Mechanize::Cached->new(); $mech->get( $url ); my $content = $mech->content( format => 'text' ); return $content; }
解决方法
sub WWW::Mechanize::Cached::get { # your code }
或者,如果get方法实际上就像你在问题中所暗示的那样,继承自LWP :: Simple –
sub LWP::Simple::get { # your code }