Skip to content

Instantly share code, notes, and snippets.

@jamesallman
Created September 8, 2015 19:05
Show Gist options
  • Save jamesallman/11abd6d565c1ec437c1a to your computer and use it in GitHub Desktop.
Save jamesallman/11abd6d565c1ec437c1a to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
my %HoH;
while (<>) {
next unless $. > 1;
chomp;
my @csv = split(/,/);
my ($epr, $source_ip, $destination_ip, $trf_port) = ($csv[0], $csv[5], $csv[6], $csv[4]);
$HoH{$epr}{source_ip}{$source_ip} = 1;
$HoH{$epr}{destination_ip}{$destination_ip} = 1;
$HoH{$epr}{trf_port}{$trf_port} = 1;
}
foreach my $epr ( keys %HoH ) {
print "set srcaddr { ";
foreach ( keys $HoH{$epr}{source_ip} ) {
print "\"$_\" ";
}
print "}\n";
print "set dstaddr { ";
foreach ( keys $HoH{$epr}{destination_ip} ) {
print "\"$_\" ";
}
print "}\n";
print "set service { ";
foreach ( keys $HoH{$epr}{trf_port} ) {
print "\"$_\" ";
}
print "}\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment