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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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!


In reply to Re: Need a better way to break out a range of addresses... by ptum
in thread Need a better way to break out a range of addresses... by RMaxwell

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found