in reply to Parsing my script out put?

I'm not sure I completely understood the requirement but try this ;
#!/usr/bin/perl use strict; my %ip1=(); my %ip2=(); while (<DATA>){ my ($ts,$ip1,undef,$ip2,$length) = split /\s+/,$_; $ts =~ s/:(\d+)$/.$1/; my ($h,$m,$s) = split ':',$ts; my $sec = $s + ($m +($h*60))*60; my $key1 = join ' > ',$ip1,$ip2; $ip1{$key1}{'sec'} = $sec; $ip1{$key1}{'ts'} = $ts; $ip1{$key1}{'length'} = $length; my $key2 = join ' > ',$ip2,$ip1; $ip2{$key2} = $key1; } for my $key (sort keys %ip1){ my $len1 = $ip1{$key}{'length'}; my $ts1 = $ip1{$key}{'ts'}; my $key2 = $ip2{$key}; my $len2 = $ip1{$key2}{'length'}; my $ts2 = $ip1{$key2}{'ts'}; my $diff = $len1 - $len2; my $sec = $ip1{$key}{'sec'} - $ip1{$key2}{'sec'}; if ($diff > 0){ print qq! ------------------- Received : $key At : $ts1 Length : $len1 Dur : $sec Sent : $key2 At : $ts2 Length : $len2 ---------------------!; } } __DATA__ 17:40:36:692166859 89.X.X.X > 63.77.X.X 65 17:40:36:808642649 63.77.X.X > 89.X.X.X 140
poj

Replies are listed 'Best First'.
Re^2: Parsing my script out put?
by MonkeyManChfKiller (Novice) on May 23, 2014 at 17:47 UTC
    Thats close to what i need, but i would need it to do two things. The output: ------------------- Received : 63.77.X.X > 89.X.X.X At : 17:40:36.808642649 Length : 140 Dur : 0.116475789996912 Sent : 89.X.X.X > 63.77.X.X At : 17:40:36.692166859 Length : 65 Needs to show how long it took to reply, so 808642649 - 692166859; also how could we have it literate over a list (or array) of different replys.
      808642649 - 692166859

      That is the duration 0.1164757

      how could we have it literate over a list (or array) of different replys.

      Can you post some more data as example ?

      poj
        Yes sir. here is a list, now i need to stress that the ips dont allways come one row after another which is why searching for the line is partly needed. But based on what we know with $ip1 and $ip2, finding the pair should be easy.
        20:21:09:366500902 94.102.XX.XX > 63.77.X.X 65 20:21:09:484721194 63.77.X.X > 94.102.XX.XX 140 20:21:10:367148691 94.102.XX.XX > 81.192.X.X 65 20:21:10:432251992 81.192.X.X > 94.102.XX.XX 140 20:21:11:367836444 94.102.XX.XX > 103.229.X.X 65 20:21:11:665980944 103.229.X.X > 94.102.XX.XX 149 20:21:12:368606359 94.102.XX.XX > 69.33.X.X 65 20:21:12:588588107 69.33.X.X > 94.102.XX.XX 149 20:21:13:369344850 94.102.XX.XX > 85.32.X.X 65 20:21:13:396157789 85.32.X.X > 94.102.XX.XX 150 20:21:14:369986605 94.102.XX.XX > 4.28.X.X 65 20:21:14:518849388 4.28.X.X > 94.102.XX.XX 142 20:21:15:370662851 94.102.XX.XX > 217.153.X.X5 65 20:21:15:437401662 217.153.X.X > 94.102.XX.XX 143 20:21:16:371366478 94.102.XX.XX > 61.93.X.X 65 20:21:16:686433904 61.93.X.X > 94.102.XX.XX 142 20:21:17:372028662 94.102.XX.XX > 82.166.X.X 65 20:21:17:469587225 82.166.X.X > 94.102.XX.XX 141