in reply to splitting a large text file and output
#!/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
|
|---|