Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Need a better way to break out a range of addresses...

by ptum (Priest)
on Mar 28, 2007 at 19:42 UTC ( #607090=note: print w/ replies, xml ) Need Help??


in reply to Need a better way to break out a range of addresses...

I would probably use split or a regex to grab the IP address string (and the last octet range) from each line of the file. Then I would step from the beginning of the range to the end of the range, constructing each IP address and writing it out as I went.

So, you'll want to do the following things:

  • Open the file (and do something sensible if that fails)
  • process each line of the file in some sort of loop (maybe a while)
  • extract the IP address substring from each line
  • determine if the IP address is a singleton or a range
  • if it is a singleton, write it out to your file or whatever
  • if it is a range, step through from the start to the end part of the last octet, constructing a series of singleton IP addresses and writing them out.

Show us what you have tried, and we'll be glad to help!


Comment on Re: Need a better way to break out a range of addresses...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2015-07-03 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (55 votes), past polls