in reply to Re^2: how to open page and follow link
in thread how to open page and follow link

links returns an array of objects of type WWW::Mechanize::Link, not an array of strings. Perhaps you want:

print $_->url(), "\n" foreach $mech->links();

Replies are listed 'Best First'.
Re^4: how to open page and follow link
by Anonymous Monk on Apr 11, 2005 at 03:35 UTC
    Yes, that did work. Thanks.

    I tried my own version of (see below) and to my suprise, it didn't work! lol.

    foreach ($mech->links()) { print "$_<br>"}
    But that's okay since yours does. Only reason I wanted to do this was to see what # my link was but from the print out, I don't think the printout order is the order I need in order to follow a specific link.

    Before I try

    $mech->get( $url ); $mech->follow_link( url_regex => qr/Frogs and Toads/i );
    I need to know I'm doing this on the right URL. Is there a way I can check this link? I tried using find_link and printing it out but it's printing out "index.cgi" and NOT the Frogs and Toads link so I have a feeling if I use follow_link it won't be going to the right link.

    How can I be sure?

    Thanks and sorry for the noobie questions

      I tried my own version of (see below) and to my suprise, it didn't work! lol.

      links returns an array of objects of type WWW::Mechanize::Link, not an array of strings.
      foreach ($mech->links()) { print "$_<br>" }
      should be
      foreach ($mech->links()) { print $_->url(), "<br>" }

      Is there a way I can check this link?

      Is there any reason to believe it's not? Why are you assuming the module isn't working? WWW::Mechanize::Link has a method called text if you can get the link as an object of that type.