#! /usr/bin/perl -w use strict; use warnings; use LWP::Simple; $max_wordlen = 6; $min_wordlen = 4; open WORDZ, "/usr/share/dict/words"; @wordz = ; @wordz = map {chomp; $_} @wordz; @wordz = grep {~ /[A-Z]/} @wordz; close WORDZ; %possibilities = (); %endings = (); for ($ctr=0; $ctr<100; ) { $w1 = $wordz[rand(scalar(@wordz))]; $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]/); $w = $w1.$w2; $doms = ""; $doms .= ".com" if (!whois($w . ".com")); $doms .= ".org" if (!whois($w . ".org")); $doms .= ".net" if (!whois($w . ".net")); next if ($doms eq ""); $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; @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 .*?(\d+)\.|s); print $pg if (!defined($howmany)); return $howmany; } sub whois { $s = `whois =$_[0]`; # print "----------------------------------------------------------\n$s\n"; return 1 unless ($s =~ /\nNo match/); return 0; }