from the archives

geoff on 2002-11-08T19:05:05

here's something I found today in my home directory from a very long time ago...

#!/usr/bin/perl



use strict;



use Math::BigInt;



my $binstring = join '', map { sprintf "%08b", $_ } split /\./, $ARGV[0];
my $decstring = Math::BigInt->new(0);



my $exp = length($binstring);



foreach my $i (1 .. $exp) {
  $decstring += substr($binstring, $i-1, 1) * (2 ** ($exp - $i));
}



(my $result = `nslookup $decstring`) =~ m/Name: *(.*)/;
print "http://$decstring would bring you to $1\n";


I think I got the idea from a LISP program in 2600 but it was so long ago that I can't remember. I do remember that, based on this program, one of my friends wrote a visual C app that accepted a normal URL and opened a browser to the translated URL. it didn't work with name-based vhosting, but was an interesting excercise anyway...