Skip to content

Instantly share code, notes, and snippets.

@alexclear
Created March 24, 2013 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexclear/5232377 to your computer and use it in GitHub Desktop.
Save alexclear/5232377 to your computer and use it in GitHub Desktop.
Tsung recorded sessions filtering script
#!/usr/bin/perl
use strict;
use warnings;
print "Processing ${ARGV[0]}, filtering domain ${ARGV[1]}\n";
open INPUT, ${ARGV[0]} or die $!;
open OUTPUT, ">${ARGV[0]}.filtered.xml" or die $!;
my $skip = 0;
while (my $line = <INPUT>) {
if ($line =~ /<request>/) {
if ($line =~ /http:\/\/(.*?)\//) {
if (!($1 eq ${ARGV[1]})) {
print "Skipping $1\n";
$skip = 1;
} else {
print OUTPUT $line;
$skip = 0;
}
} else {
if ($skip == 0) {
print OUTPUT $line;
} else {
# print "Skipping...\n"
}
}
} else {
print OUTPUT $line;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment