open my $file, '<', "$filename" or die $!; my $text = do { local $/; <$file> }; # get the part you want my ($wanted) = $text =~ /Well(.*)/s; # or delete the stuff you don't want $text =~ s/.*Well//s;