my $mech = new WWW::Mechanize( max_redirect => 20, autocheck => 1, onerror => \&onFetchError, onwarn => \&onFetchWarn ); # i cannot use max_size because i get a 403 # $mech->max_size("10240"); # so here is what i came up with: $mech->get($myUrl,":content_cb"=> \&myCallback); sub myCallback{ my ($data, $response, $protocol) = @_; my $totalData .= $data; if( (length($totalData ) / 1024) > 10 ){ #I want to stop the transfer now #but it's not working this way... $mech = undef; } }