Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Display all IPs in given range

by Discipulus (Canon)
on Oct 17, 2016 at 09:48 UTC ( [id://1174133]=note: print w/replies, xml ) Need Help??


in reply to Display all IPs in given range

NetAddr::IP can be useful in this case: you can adapt to fill in your array of valid IPs in your subnet (you consider the broadcast one as valid?) see Managing your IP space with Perl
use NetAddr::IP; my $ip = new NetAddr::IP('10.0.0.0/30'); while ($ip < $ip->broadcast) { print "ip = $ip\n"; $ip ++; }

L*

PS the module also has ->first() and ->last() methods that are what you are looking for.

PPS fixed module link thanks to hippo

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Display all IPs in given range
by Noosrep (Novice) on Oct 17, 2016 at 10:30 UTC

    Yeah, I consider broadcast as valid. Looks interesting but I'm having some problems with installing the module (dependencies) so I haven't tested it yet.

    PS: call is anonymous but forgot to log in appearantly..

      forgot to log in appearantly.. if so welcome to the monastery Noosrep!

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

        Thanks! I tried your code but it gives me Can't call method "broadcast" on an undefined value error. However, I will try tinkering some more with it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1174133]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-25 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found