TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Domain names!



Hi all:

For a lark I threw together a perl script that picks two words
at random from /usr/dict/words, then concatenates them.  I'm
sure it's been done before, but it seemed to follow the train
of discussion...

Sample output:

smashBator
GoaSteen
wavekick
wheatbask
stumpkayo
vitamad
watchchild
beanserf
wheatclay
supgross

----------------------------
#!/usr/bin/perl -w

use strict;
use vars qw[ @WORDS ];

srand( time() ^ ($$ + ($$ << 15)) );

open(WORDS,"/usr/dict/words") or die "Can't read /usr/dict/words: !$\n";
while (defined(my $tmp = <WORDS>)) {
   chomp $tmp;
   push(@WORDS,$tmp) unless (length($tmp) > 5);
}
close WORDS;

foreach (1 .. ($ARGV[0] || 10)) { print &make_dn, "\n"; }

sub make_dn { return("$WORDS[rand($#WORDS)]$WORDS[rand($#WORDS)]"); }
----------------------------

John