use strict; use warnings; sub findWords { my ($sText, $sEndSentence, $reStart, $reEnd)=@_; local $/=$sEndSentence; open(LONG_STRING, "<", \$sText) || die "Can't open string"; while (my $line = ) { chomp $line; if (($line =~ $reStart) && ($line =~ $reEnd)) { print "match: $line\n"; } else { print "no match: $line\n"; } } } findWords("a b c. Nullam est libero.Nullam est augue", '.' , qr(^\s*Nullam) , qr((?:libero|augue)\s*$));