]> git.sesse.net Git - bursty/blob - correlate.pl
Add a script to correlate sender and receiver logs.
[bursty] / correlate.pl
1 #! /usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 my $fh;
7 my %seen_recv = ();
8
9 # Receiver
10 open $fh, "<", $ARGV[1]
11         or die "$ARGV[1]: $!";
12 while (<$fh>) {
13         tr/\r\n//d;
14         /^(\d+)$/ or next;
15         $seen_recv{$1} = 1;
16 }
17 close $fh;
18
19 # Sender
20 open $fh, "<", $ARGV[0]
21         or die "$ARGV[0]: $!";
22 while (<$fh>) {
23         tr/\r\n//d;
24         /^\d+(?: \d+)* $/ or next;
25         for my $n (split) {
26                 if (exists($seen_recv{$n})) {
27                         print "$n ";
28                 } else {
29                         print "$n* ";
30                 }
31         }
32         print "\n";
33 }
34 close $fh;
35
36