open(F0, $ARGV[0]); open(F1, $ARGV[1]); open(F2, ">$ARGV[2]"); $line_no=$line_stop=0; while () { while (s/^[\ \t]//g) {}; while (s/[\ \t]$//g) {}; s/\r\n//;s/\t+/\t/;chomp; /^[0-9]+/; $line=$'; $line_no=$&; while ( && ($line_stop++ < $line_no)) { while (s/^[\ \t]//g) {}; while (s/[\ \t]$//g) {}; s/\r\n//;s/\t+/\t/;chomp; print "$_\n";} print F2 $IP, "\t$line\n" if /[0-9]+\//; } close F0; close F1; close F2; #### 1.0.129.197 1.0.131.49 1.0.131.74 1.0.138.143 1.0.138.154 1.0.139.72 #### 3 PORT state protocol 3 80/tcp closed http 3 443/tcp closed https 3 8080/tcp open http-proxy 5 80/tcp open http 5 443/tcp filtered https 5 8080/tcp filtered http-proxy