> On 20010925.1701, Bob Miller said ...
>
> Rob Hudson wrote:
> 
> > I want to pick a random word from dict/words file, basically pick a
> > random line in a file.
> 
> $ perl -ne '$l = $_ if ! int rand $n++; END { print $l }' /usr/dict/words

I found another version using perl and avoids the 'slurp the whole
file into memory' approach...

cat /usr/share/dict/words | \ 
  perl -e 'srand; rand($.) < 1 && ($line = $_) while <>; print $line;'


I can't see what yours is doing, though.  Care to explain?

Thanks,
Rob

--
Rob <rob_at_euglug_dot_net>
my @euglugCode = qw(v+++ e--- eug+ bsd+++ gnu+ S+++);

Reply via email to