in reply to Using example script correctly for opening cpan module
Edit: Did some testing, and indeed quoting the regexp seems to make Mech happy. This seems to work:
or, more concisely:my $link = $browser->find_link( text_regex => qr{$module_name} ); $browser->follow_link( url => $link->url );
Cheers!$browser->follow_link( url => $browser->find_link(text_regex => qr{$mo +dule_name})->url );
earlier ... Hmm, the string 'WWW::Mechanize' works as a pattern in a hand-rolled regexp . . .
The docs for WWW::Mechanize only mention text_regex as an attribute of find_link, not follow_link, and also that a regexp passed to follow_link is matched against the URL, not the display text.
Also, maybe it will help to quote your regexp? Try:
or maybe$browser->follow_link( url => $browser->find_link( text_regex => $modu +le_name )->url );
Hope this helps!$browser->follow_link( text_regex => qr{$module_name} );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using example script correctly for opening cpan module
by Aldebaran (Curate) on Sep 09, 2015 at 07:22 UTC |