如果我这样做
#!/usr/local/bin/perl
use warnings;
use 5.014;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
my $res = $ua->get( 'http://www.perl.org' );
我可以调用HTTP::Response
这样的方法
say $res->code;
是否有可能HTTP::Request
从对象调用方法$res
或需要显式创建HTTP::Request
对象?
my $ua = LWP::UserAgent->new();
my $method;
my $res = $ua->get( 'http://www.perl.org' );
$ua->add_handler( request_prepare => sub { my( $request, $ua, $h ) = @_; $method = $request->method; }, );
say $method; # Use of uninitialized value $method in say