my $stream2 = $mech1->{content}; (my $stream_chunk) = $stream2 =~ /bottomPagingCell(.*)bottom/; # <---- fails here if (/javascript:SubmitFormPost\(\"(.*)\"\)/) { mech1->get($1); } else { # no new page }