in reply to Random word generator

I'm not familiar with solaris, but as it's a *nix system I'd imagine you'll find a wordlist in somewhere like /usr/dict/words.

Using this as a base, it's fairly trivial to generate random words. You can restrict the length with the built in length function.

Alternatively, there is always CPAN - Data::Random::WordList, for example. You could use that to generate the words, and again use length to throw away the ones that are not the right length.

Update: And for no other reason than I felt like it ;), here is a short snippet of code that demonstrates how one might do this (in this case, using shuffle() from List::Util):

#!/usr/bin/perl -l use strict; use warnings; use List::Util qw/shuffle/; my $wordlist = '/usr/share/dict/words'; my $length = 10; my $numwords = 10; my @words; open WORDS, '<', $wordlist or die "Cannot open $wordlist:$!"; while (my $word = <WORDS>) { chomp($word); push @words, $word if (length($word) == $length); } close WORDS; my @shuffled_words = shuffle(@words); print for @shuffled_words[0 .. 9];

Hope this helps,
Darren :)

Replies are listed 'Best First'.
Re^2: Random word generator
by rooneyl (Sexton) on Feb 27, 2008 at 19:27 UTC
    Thank you for your help. Much appreciated. I like the List::Util version, the Data:Random:wordlist isn't that good at returning words of a given length. I needed to get a large list to ensure a number of words of the length required.