Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Net::Netmask -> match usage problems
Hey guys...I am having some problems which may be a newbie type of
questions but i figured I would ask...

I am using the Net::Netmask module to work with a subnet and try to
identify if a given ip is part of that subnet.

Taking some from

http://www.cpan.org/modules/by-modu...k-1.9007.readme

We have an $subnetIp, and a box $IP.  We created a

$subnetIp = "148.1.2.0";
$IP = "148.1.2.3";
$net = new Net::Netmask($subnetIp);
$result = $net->match($IP);
$result += 0;

if ( $result ) {
# Part of the Subnet
} else {
# Not Part of the Subnet
}

Now for some reason, it always returns 0 or false which causes it to
always to run the not part of the subnet code.

What am I doing wrong?

Eric


Report this thread to moderator Post Follow-up to this message
Old Post
ebresie@usa.net
04-14-05 08:55 PM


Re: Net::Netmask -> match usage problems
On 2005-04-14, ebresie@usa.net <ebresie@usa.net> wrote:
> Hey guys...I am having some problems which may be a newbie type of
> questions but i figured I would ask...
>
> I am using the Net::Netmask module to work with a subnet and try to
> identify if a given ip is part of that subnet.
>
> Taking some from
>
> http://www.cpan.org/modules/by-modu...k-1.9007.readme
>
> We have an $subnetIp, and a box $IP.  We created a
>
> $subnetIp = "148.1.2.0";
> $IP = "148.1.2.3";
> $net = new Net::Netmask($subnetIp);
> $result = $net->match($IP);
> $result += 0;
>
> if ( $result ) {
>   # Part of the Subnet
> } else {
>   # Not Part of the Subnet
> }
>
> Now for some reason, it always returns 0 or false which causes it to
> always to run the not part of the subnet code.
>
> What am I doing wrong?

You're not telling Net::Netmask what the netmask of the subnet is.
Using either

$subnetIp = "148.1.2.0/24";   # 255.255.255.0

or

$net = new Net::Netmask($subnetIp, "255.255.255.0");

will correct the problem (substitute the right netmask for your
situation, of course).

Arjen


Report this thread to moderator Post Follow-up to this message
Old Post
Arjen Laarhoven
04-14-05 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:05 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.