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

Hi all ... I have a question about read out a a return value. I am writing a script that uses WWW::Mechanize and the snippet looks like this. ( i wont bore you with all the code )
my $result = $mech->get( $url );
In $result i get the following (produced with Data::Dumper, this is not code but i use the tag's anyway)
$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => '<!DOCTYPE HTML PUBLIC' MORE HTML STUFF', '_rc' => 404, '_headers' => bless( { 'x-meta-generator' => 'IBM Web +Sphere Studio', 'connection' => 'close', 'client-response-num' => 1, 'last-modified' => 'Wed, 08 Oc +t 2003 17:22:25 GMT', 'date' => 'Tue, 01 Jun 2004 14 +:41:53 GMT', 'client-peer' => '217.127.206. +73:80', 'content-length' => '1045', 'client-date' => 'Tue, 01 Jun +2004 13:00:12 GMT', 'etag' => 'W/"1045-10656337457 +05"', 'content-type' => 'text/html; +charset=ISO-8859-1', 'via' => '1.1 toplist.linkworl +d.ws', 'title' => 'Burke-eSolutions. +Control Acceso Clientes', 'server' => 'Apache Coyote/1.0 +' }, 'HTTP::Headers' ), '_msg' => '/error/HTTP_BAD_GATEWAY.html.var', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://toplist.linkworld.ws/cgi-bin/rankem.cgi?id=pala')}, 'URI::htt +p' ), '_headers' => bless( { 'user-a +gent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)', 'accept +-encoding' => 'identity' }, 'HTTP: +:Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' );
The question is : Why can i read the content just fine with $result->content And can i not read _rc with $result->rc (nor can i do it with $result->_rc) I hope you guy's can help Paul

Replies are listed 'Best First'.
Re: WWW::Mechanize readout vars
by antirice (Priest) on Jun 01, 2004 at 13:25 UTC

    Check out $result->status_line(). It returns in the form <code> <message>.

    Oh yeah, here are the docs.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Re: WWW::Mechanize readout vars
by LTjake (Prior) on Jun 01, 2004 at 15:27 UTC

    From the WWW::Mechanize docs:

    $mech->get($url)

    Given a URL/URI, fetches it. Returns an HTTP::Response object.

    So, from the HTTP::Response docs:

    $r->code( $code )

    This is used to get/set the code attribute.

    RTFM++

    --
    "Go up to the next female stranger you see and tell her that her "body is a wonderland."
    My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
    " (src)