domains, top level, collecting a list of

Discussion in 'Perl Misc' started by wardbayern@yahoo.com, Jan 29, 2008.

  1. Guest

    Is there a perl way, verses finding a published list, to collect
    current top level domain names?

    Thanks.
    , Jan 29, 2008
    #1
    1. Advertising

  2. wrote:
    > Is there a perl way, verses finding a published list, to collect
    > current top level domain names?


    $ perl -MSocket -le'
    # Search from 1.0.0.1 through 255.255.255.254
    for ( my $ip = 16_777_217; $ip < 4_294_967_295; ++$ip ) {
    # Skip 127.0.0.0 through 127.255.255.255

    next if $ip >= 2_130_706_432 && $ip <= 2_147_483_647;

    # Skip 10.0.0.0 through 10.255.255.255 -- RFC1918

    next if $ip >= 167_772_160 && $ip <= 184_549_375;

    # Skip 172.16.0.0 through 172.31.255.255 -- RFC1918

    next if $ip >= 2_886_729_728 && $ip <= 2_887_778_303;

    # Skip 192.168.0.0 through 192.168.255.255 -- RFC1918

    next if $ip >= 3_232_235_520 && $ip <= 3_232_301_055;



    $TLD{ lc( $1 ) }++ if gethostbyaddr( pack( "N", $ip ), AF_INET ) =~
    /\.(\w+)\z/;
    }
    print for sort keys %TLD;
    '


    John
    --
    Perl isn't a toolbox, but a small machine shop where you
    can special-order certain sorts of tools at low cost and
    in short order. -- Larry Wall
    John W. Krahn, Jan 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frederic HOUDE
    Replies:
    4
    Views:
    595
    Frederic HOUDE
    Aug 31, 2004
  2. David Pratt

    Collecting list of module dependencies

    David Pratt, Jan 1, 2007, in forum: Python
    Replies:
    0
    Views:
    242
    David Pratt
    Jan 1, 2007
  3. pabbu
    Replies:
    8
    Views:
    721
    Marc Boyer
    Nov 7, 2005
  4. Cuthbert
    Replies:
    8
    Views:
    430
    Ancient_Hacker
    Sep 13, 2006
  5. Gerardo Herzig
    Replies:
    5
    Views:
    286
    Bjoern Schliessmann
    Sep 21, 2007
Loading...

Share This Page