will never match. Update: I am an idiot. This will hopefully teach me to pay closer attention to which $ is meant as end of line, and which is meant as literal $. (And I will start using \z in my regexps...)
### WRONG ###
while (<BIG>) {
open OUT, ">outfile_" .$i++;
if ( m/^\$\n$/ ) {
### CORRECT ###
open OUT, ">outfile_" .$i++;
while (<BIG>) {
if ( m/^\$\n$/ ) {