in reply to regex question: store multiple lines as a string

You can change $/ at any time - even alternating as you read a single file. This example demonstrates the flexibility you have, but note that each I/O operation could be on a different file handle as easily as on the same one.

use strict; use warnings; for (0..2) { my $line1 = do { local $/ = "\n\n"; <DATA> }; print "got a line1: \"$line1\"\n" if(defined($line1)); my $line2 = do { local $/ = "paragraph"; <DATA> }; 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.