http://qs321.pair.com?node_id=372541

chiburashka has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: What's the bug ?
by tcf22 (Priest) on Jul 07, 2004 at 20:52 UTC
    You need to create a Net::IP object. Try this
    #!/usr/local/bin/perl use strict; use Net::IP; my $ip = new Net::IP('193.0.1/24') or die (Net::IP::Error()); print ("Mask : ", $ip->mask());
    PS. using strict would have prevented this error.

    Update: Added IP in constructor. Directly from CPAN.

    - Tom

Re: What's the bug ?
by tomhukins (Curate) on Jul 08, 2004 at 00:24 UTC

    Imagine you wrote the following:

    #!/usr/local/bin/perl print $message;

    $message is undefined, so print will output nothing. If you use the strict pragma, it will complain alert you that you forgot to define $message.

    The same thing is happening in your program. You try to do something with $ip before you have declared it. In this case, you need to instantiate $ip as a Net::IP object as suggested by tcf22.

Re: What's the bug ?
by Anonymous Monk on Jul 07, 2004 at 22:09 UTC
    Now, how to fix it ?
    You open your eyes and RTFM

    Considered: tomhukins delete: no useful content
    Unconsidered: ysth - Keep/Edit/Delete = 12/0/9 - enough keep votes