rendered paste body#!/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 /^\<testResults/, $_);
if($count == 0) {
$filename = $file . "-" . $files_counter . ".jtl";
print "Opening $filename\n";
open(FH2, "> $filename") or die "Unable to open file: $filename\n";
print FH2 '<?xml version="1.0" encoding="UTF-8"?>';
print FH2 "\n";
print FH2 '<testResults version="1.2">';
print FH2 "\n";
$count++;
}
if (grep /\<\/httpSample/, $_ ) {
$count++;
}
print FH2 $_;
if ($count == $max_records + 1) {
$count = 0;
$files_counter++;
print FH2 "</testResults>\n";
print "Closing $filename\n";
close(FH2);
}
}
print "All done\n";