# ... having got to a certain page $mech->content() =~ m/LONGFIDDLYCAPTURINGREGEXHERE/; my $place_where_the_links_are = $1; # get the links from that place and continue