#!/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
如何在此脚本中使用get()
覆盖my_get()
?
sub my_get {
my $url;
my $mech = WWW::Mechanize::Cached->new();
$mech->get( $url );
my $content = $mech->content( format => 'text' );
return $content;
}
答案 0 :(得分:10)
sub WWW::Mechanize::Cached::get {
# your code
}
或者,如果get
方法实际上正如您所暗示的那样,则继承自LWP :: Simple -
sub LWP::Simple::get {
# your code
}