Skip to content

Instantly share code, notes, and snippets.

@aliesbelik
Forked from alexclear/tsung-filter.pl
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliesbelik/2173a18734205f5886c8 to your computer and use it in GitHub Desktop.
Save aliesbelik/2173a18734205f5886c8 to your computer and use it in GitHub Desktop.
#!/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