You don't show the contents of your input file, but I am guessing something like:

IP Address 1.2.3.4 Gateway 1.2.3.1

When you read a line from your input file into $_, it includes the line termination character ("\n"). If there is no space character after the IP address in your configuration file, then you will end up with $ff set to something like "10.6.10.5\n" and $fk set to something like "10.6.10.5\n:255.255.255.0", when what you need is "10.6.10.5:255.255.255.0".

There are several ways to deal with this, but one good one for you to learn is to use the chomp function to remove the line termination from your input. You could change your input loop to be like the following:

while(<F>) { chomp; # Remove the "\n" from the end of the line # now use $_ }

In reply to Re: Net::Netmask not working with scalar variable by ig
in thread Net::Netmask not working with scalar variable by sagarkha

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.