use strict; use warnings; for (0..2) { my $line1 = do { local $/ = "\n\n"; }; print "got a line1: \"$line1\"\n" if(defined($line1)); my $line2 = do { local $/ = "paragraph"; }; print "got a line2: \"$line2\"\n" if(defined($line2)); } __DATA__ This is a paragraph with two lines. This is another paragraph with two lines. This is a third paragraph. This paragraph has three lines.