http://paperlined.org/this_website/why_paperlined/domain_name_generator.pl
#! /usr/bin/perl -w
use strict;
use warnings;
use LWP::Simple;
my $max_wordlen = 6;
my $min_wordlen = 4;
open WORDZ, "/usr/share/dict/words" or die;
my @wordz = <WORDZ>;
@wordz = map {chomp; $_} @wordz;
@wordz = grep {~ /[A-Z]/} @wordz;
close WORDZ;
my %possibilities = ();
my %endings = ();
for (my $ctr=0; $ctr<100; ) {
my $w1 = $wordz[rand(scalar(@wordz))];
my $w2 = $wordz[rand(scalar(@wordz))];
# $w2 = $wordz[rand(scalar(@wordz))] until (substr($w1,0,1) eq substr($w2,0,1));
next if (length($w1)>$max_wordlen || length($w2)>$max_wordlen);
next if (length($w1)<$min_wordlen || length($w2)<$min_wordlen);
next if ($w1 =~ /[A-Z]/ || $w2 =~ /[A-Z]/);
my $w = $w1.$w2;
my $doms = "";
$doms .= ".com" if (!whois($w . ".com"));
$doms .= ".org" if (!whois($w . ".org"));
$doms .= ".net" if (!whois($w . ".net"));
next if ($doms eq "");
my $many = google_howmany("%22$w1+$w2%22");
if ($many == 0) {
print STDERR " "x20, "$w1 $w2\n";
} else {
print STDERR "$w1 $w2 $many $doms\n";
}
next if ($many == 0);
$possibilities{$w} = $many;
$endings{$w} = $doms;
$ctr++;
}
#sub sc {$possibilities{$a} <=> $possibilities{$b}}
#@p = sort &sc, keys %possibilities;
my @p = keys %possibilities;
foreach (@p) {
printf "%4d %-30s %s\n", $possibilities{$_}, $_, $endings{$_};
}
sub google_howmany {
# print STDERR "Trying $_[0]\n";
my $pg = get "http://www.google.com/search?q=$_[0]";
$pg =~ s/,//gs;
if ($pg =~ / - did not match any documents\./) {
return 0;
}
my ($howmany) =
($pg =~ m|Results .*? of .*?<b>(\d+)</b>\.|s);
if (!defined($howmany)) {
print $pg;
exit;
}
return $howmany;
}
sub whois {
my $s = `whois =$_[0]`;
# print "----------------------------------------------------------\n$s\n";
return 1 unless ($s =~ /\nNo match/);
return 0;
}
Generated by GNU enscript 1.6.4.