The reads a line from F1while (<F1> && ($line_stop++ < $line_no)) { while (s/^[\ \t]//g) {} };
Your code is so confusing, I have no idea what it is really supposed to do. But I took a wild ass guess based upon just looking at the input files. Code below which uses a tricky feature of opening a Perl variable like an input file so that I can show everything as a single runnable Perl program.
Maybe back up and explain what you are trying to do?
use strict; use warnings; my $IP_file = << 'END'; 1.0.129.197 1.0.131.49 1.0.131.74 1.0.138.143 1.0.138.154 1.0.139.72 END my $Port_file = << 'END'; 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 END my $output_file; open my $IP, "<", \$IP_file or die "unable to open IP file for +reading $!"; open my $PORT, "<", \$Port_file or die "unable to open port file fo +r reading $!"; open my $OUT, ">", \$output_file or die "unable to open output file +for writing $!"; <$PORT>; # throw away first line ion port file while (defined (my $ip_line =<$IP>) and defined (my $port_line = <$POR +T>)) { chomp $ip_line; $port_line =~ s/^\d+\s+/$ip_line /; print "$port_line"; } __END__ Prints: 1.0.129.197 80/tcp closed http 1.0.131.49 443/tcp closed https 1.0.131.74 8080/tcp open http-proxy 1.0.138.143 80/tcp open http 1.0.138.154 443/tcp filtered https 1.0.139.72 8080/tcp filtered http-proxy
In reply to Re: reading the wrong input file out of 2 opened file
by Marshall
in thread reading the wrong input file out of 2 opened file
by perl_boy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |