die "perl port-state-service+IP-mem-list-indirect-ARGV-line-IP-start.pl " if $#ARGV < 3; die "ARGV[3] MUST contain just a number: got =>$ARGV[3]<=" if $ARGV[3] =~ /[^0-9]/; sub idx { print F2 $IP[$line_no - 1], "\t$line\n" } open(F0, $ARGV[0]); open(F1, $ARGV[1]); open(F2, ">$ARGV[2]"); $line_no=$ARGV[3]; while () { while (s/^[\ \t]//g) {}; while (s/[\ \t]$//g) {}; s/\r\n//;chomp; push @IP,$& if /[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]\.[0-2]?[0-9]?[0-9]/; } close F1; print F2 "IP\t\tport\tstate\tprotocol\n\n"; while () { while (s/^[\ \t]//g) {}; while (s/[\ \t]$//g) {}; s/\r\n//;s/\t+/\t/;chomp;/^[0-9]+/;$line=$';$line_no=$&; $line =~ s/^[\t\ ]+//g;$line =~ s/[\t\ ]+$//g ; &idx; } close F0; close F2;