You need to check your open calls for errors, as shown in "open" Best Practices - once you've got a more specific error message, we can help better. (And if you're not already, Use strict and warnings!)

Update: While what I wrote above is correct, looking at your code again, there are further issues: after while (<F1> ... reads the input file, it doesn't automatically reset to the beginning of the file. Also, since you're not using the while (<F1>) form and instead have added additional conditionals in the while condition, Perl is not going to assign the current line to $_ for you like it is with while (<F0>). And another thing I see is that you never reset $line_stop.

So overall, because even I am having a bit of trouble understanding what your code is supposed to be doing, I think you'll need to take a step back and rethink your logic. Note that instead of nested loops, a common approach is to first read one of the files into a hash (or other data structure), and then use that for lookups while looping over the other file. I would suggest you take a look at perlintro and the Basic debugging checklist.

Update 2: Here's a suggestion: You can read the list of IP addresses into an array by simply saying chomp( my @ips = <$ip_filehandle> ); (see also chomp). Then, in a basic while loop, read the lines of the file with the port specifications, and you can then select the IP address from the array - remember that arrays are indexed starting from 0, while your lines appear to be numbered starting from 1.


In reply to Re: can't read the 2nd input file (updated) by haukex
in thread can't read the 2nd input file by perl_boy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.