Thanks for replying guys,

>See the docs regarding the autocheck option.

I just checked the doc and modified my code to turn it on, but it still does not work:

package MyMech; use base qw(WWW::Mechanize); sub new { my $class = shift or die $!; my $self = $class->SUPER::new( autocheck => 1, ); return bless $self, $class; } sub get { my $self = shift or die $!; $self->SUPER::get(@_); }

>Does the superclass die on error?

Yeah, it dies when the server is not responding:

Error GETing (URL): Can't connect to (URL) (Bad hostname) at ***.pl line **

>Have you tried the $self->success() method?

Oh God it works... I changed the tester code from:

my $mech = MyMech->new; $mech->get("http://google.com/"); print $mech->title."\n";

to:

my $mech = MyMech->new; $mech->get("http://google.com/"); print $mech->title."\n" if $mech->success;

Now it displays the error code. Thank you so much...

But I don't get why it came to work by putting the if statement. In addition now it works only with 'autocheck' even though it didn't work before i put the if statement.

Anyway... Thank you guys so much, now I can move on :)


In reply to Re^2: Question about inheritance of WWW::Mechanize by ryo0ka
in thread Question about inheritance of WWW::Mechanize by ryo0ka

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.