#!/usr/bin/perl -w $file = $ARGV[0]; open(_FH, "<$file") or die "Unable to find $file"; $count = 0; $files_counter=1; $max_records = 750000; print "Writing $max_records per file\n"; while (<_FH>) { next if (grep /^\<\?xml/, $_); next if (grep /^\ $filename") or die "Unable to open file: $filename\n"; print FH2 ''; print FH2 "\n"; print FH2 ''; print FH2 "\n"; $count++; } if (grep /\<\/httpSample/, $_ ) { $count++; } print FH2 $_; if ($count == $max_records + 1) { $count = 0; $files_counter++; print FH2 "\n"; print "Closing $filename\n"; close(FH2); } } print "All done\n";