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

hey i have a problem with using mechanize... im trying to find a link on a page but i dont know how to get it to return the url this is the following command

$link = $mech->find_link( url_regex => qr/hello.you/i );

it always returns a hash refrence i cant get it to return the actual link

Replies are listed 'Best First'.
Re: help with hash reference
by quester (Vicar) on Apr 01, 2007 at 07:27 UTC
    According to the documentation for WWW::Mechanize, it should return a WWW::Mechanize::Link object. In the documentation for WWW::Mechanize::Link you should be able to get the actual URL with the url method of the object, like so:
    $url=$link->url();

      $link->URI() will also give you one of Uri's URI::URL objects, which will stringify nicely.

      I'd imagine that you can also do whatever the regex was to do by calling $link->URI()->param or other methods to get or replace which ever bits or the uri you want to change

      @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;