in reply to How to match regex over multiline file

use strict; use warnings; my $text = <<EOT; I probably do not understand your requirement. Is it not as simple as reading the file line by line, removing all newlines and adding a newline after all full stops, question and exclamation marks? After that operation each line is one sentence. EOT open my $fn, "<", \$text; while(<$fn>){ chomp; s/[.!?]\K\s*/\n/g; print; } close $fn;