in reply to splitting a large text file and output

Adding yet another solution to the mix.. I assumed that new files start with VECT and that no blank lines go into output files. If a file handle like OUT below is open to one file and an open is issued to a new file, that causes an automatic close of the previous file. So the code is actually very simple. Code of course assumes that first non-blank line is a VECT line.
#!/usr/bin/perl -w use strict; my $num =1; while (<DATA>) { next if /^\s*$/; #skip blank lines if (/^VECT/) { open OUT, '>', "file$num" or die "unable to open file$num $!\n"; $num++; } print OUT $_; } close OUT; #to finish the very last file in a clean way __DATA__ VECT 1 1 1 2 2 2 3 3 3 VECT 4 4 4 5 5 5 6 6 6