Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

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

You only resolve addresses in 4-number dotted decimal notation. What about addresses like 0177.1, better known as 127.0.0.1? OK, they are not very frequent, but still...

Moreover, an address is numeric if its last part is numeric, not the first. That is, all TLD are non-numeric.

To formalize:

  • an address (name or number) is made up of a number of components separated by dots
  • If the last component is a number (matches \d+), the address is numeric
  • the components of a non-numeric address match [a-zA-Z0-9-] (no, you can't have an 'underscore' in your domain names) (and this might change once non-ASCII-7 characters are allowed in names)
  • each component of a numeric address is to be interpreted as a base-16 number if it matches /^0x/i, as a base-8 number if it matches /^0/, otherwise as a base-10 number
  • a numeric address is composed of 1,2,3 or 4 components:
    • if it's one component, it must be withit the range 0...(2^32-1), and represents the entire address
    • if it's two components, the first must be in the range 0..255, and the second in 0..(2^24-1), and the address is $1<<24+$2 (I use $1, $2, and so on for the various components, left-to-right)
    • if it's three components, the first and the second must be in 0..255, and the third in 0..(2^16-1), and the address is $1<<4+$2<<16+$3
    • If it's four components, each must be in the range 0..255, and the address is $1<<24+$2<<16+$3<<8+$4

Hope this clears up the notation.

-- 
        dakkar - Mobilis in mobile

In reply to Re: Simple Resolver Function by dakkar
in thread Simple Resolver Function by jbaribeault

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 perusing the Monastery: (5)
As of 2024-03-29 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found