Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

If autocheck is on, and request is not success, content isn't set.
#!/usr/bin/perl -- use strict; use warnings; use WWW::Mechanize; my $url = 'http://code.google.com/p/www-mechanize/wiki/WikiStart'; # in case WikiStart gets added $url = 'http://code.google.com/p/www-mechanize/w/list/notfound'; { # no content my $ua = WWW::Mechanize->new( autocheck => 1 ); eval { $ua->get($url); 1 } or print $@; print join ' ', $ua->response->status_line, $ua->ct, $ua->res->content_length, length $ua->content, "\n"; } print "\n----\n"; { # set content manually my $ua = WWW::Mechanize->new( autocheck => 1 ); eval { $ua->get($url); 1 } or print $@; $ua->update_html($ua->res->decoded_content) if $ua->{'autocheck'}; print join ' ', $ua->response->status_line, $ua->ct, $ua->res->content_length, length $ua->content, "\n"; } print "\n----\n"; { # no autocheck, content set my $ua = WWW::Mechanize->new( autocheck => 0 ); eval { $ua->get($url); 1 } or print $@; print join ' ', $ua->response->status_line, $ua->ct, $ua->res->content_length, length $ua->content, "\n"; } __END__ Error GETing http://code.google.com/p/www-mechanize/w/list/notfound: N +ot Found at bug.autocheck.t line 14 Use of uninitialized value in length at bug.autocheck.t line 15. 404 Not Found text/html 1385 0 ---- Error GETing http://code.google.com/p/www-mechanize/w/list/notfound: N +ot Found at bug.autocheck.t line 23 404 Not Found text/html 1385 1385 ---- 404 Not Found text/html 1385 1385
should autocheck affect content, whats the right thing?

Replies are listed 'Best First'.
Re: WWW::Mechanize autocheck content
by ikegami (Patriarch) on May 17, 2009 at 19:03 UTC
    The author probably didn't consider the situation where the exception is caught. Feel free to submit a bug report.