On tor, 2004-09-30 at 14:30, Randal L. Schwartz wrote:
> The module that I've designed a half dozen times in my head but never
> implemented would simply overload LWP::UserAgent's "simple_request"
> method with one that did caching transparently.
>
Ok, I'll give it a shot. I experimented with how to overload
simple_request and came up with the following. Does it seem right so
far?
use strict;
use LWP::UserAgent;
BEGIN
{
print "Installing\n";
$LWP::Simple::FULL_LWP++;
my $org_simple_request = \&LWP::UserAgent::simple_request;
{
no warnings;
*LWP::UserAgent::simple_request = sub
{
my($self, $request, $arg, $size) = @_;
print "Overloaded\n";
return &$org_simple_request( $self, $request, $arg, $size );
}
}
}
1;
/Mattias