What you get is a warning about an undefined $_.

If you look closely you see that it complains about the errormode-sub.

This is triggered because you fail to remove the newlines from the ips you read from the file (after <IPS> $_ contains not "1.2.3.4" but "1.2.3.4\n" - get rid of that with a chomp), so the ip you pass to Net::Telnet is not valid and so the errormode-sub is triggered.

In this sub $_ is no longer the value you read from the file, probably because Net::Telnet localized $_.

If you would use a lexical variable (rather than $_), e.g.

while (my $ip = <IPS>) { chomp $ip; ...

You could then refer to this $ip variable in your errmode-sub (which would then be a closure).


In reply to Re: Telnet list of IP and get information stored to a file by morgon
in thread Telnet list of IP and get information stored to a file by sanju7

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.