use strict; my $html; open( HTML, "<", "some.html" ); # let's suppose the data is in this file { local $/; $html = ; #read all the html data into one string } # if you expect just one match (or only want the first one): my ( $match ) = ( $html =~ /Marker 1(.*?)Marker 2/s ); # alternatively, if there are two or more and you want them all: my @matches = ( $html =~ /Marker 1(.*?)Marker 2/gs );