use strict; use warnings; open FILE_IN, 'results.txt'; $/ = undef; my $records = ; my $text = ""; ($text) = $records =~ m/(.*)<\/html>/; print "$text"; close FILE_IN; close FILE_OUT;