my $text = do { local $/; }; if ($text =~ /^Header1.*?END LIST/m) { .... }