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

Hi Monks

Apologies but 2 questions for you today regarding WWW:Mechanize:

1) When using the $mech->follow_link(...) $mech->find_link( ... ) if one wanted more than 1 conditional for selecting links what would the syntax be for doing this e.g

my @cgi_links = $mech_cgi->find_all_links( url_regex => qr/protein/ );

but the following does'nt?

my @cgi_links = $mech_cgi->find_all_links( url_regex => qr/(protein && + amino)/ );

Can anyone point me in the right direction or know the answer?

2) what is the best practice for only following/selecting the same link once and not following it again multiple times if the link is present more than once on a web-page?

many thanks and best wishes

Dan

Replies are listed 'Best First'.
Re: WWW:Mechanize conditional finding/following links and redundant link avoiding?!
by roboticus (Chancellor) on Oct 24, 2011 at 19:02 UTC

    fraizerangus:

    Read perldoc perlre to learn how to create regular expressions. Your regular expression isn't searching for what you think it is...

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.