in reply to Estimating Vocabulary
It's based on "How do I select a random line from a file?" in perlfaq5. I'd be interested in seeing if anybody else has a better means of extending this algorythm to report multiple entries.my(@lines, $line); open(FILE, shift) || die; until( scalar @lines == $ARGV[0] ){ seek(FILE, 0, $. = 0); rand($.) < 1 && ($line = $_) while <FILE>; push(@lines, $line); } print @lines, "wc -l could have told you this is $. words\n";
--
perl -pe "s/\b;([st])/'\1/mg"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Estimating Vocabulary
by I0 (Priest) on Mar 28, 2002 at 00:41 UTC | |
by belg4mit (Prior) on Mar 28, 2002 at 01:00 UTC | |
by I0 (Priest) on Mar 28, 2002 at 01:39 UTC | |
by belg4mit (Prior) on Mar 28, 2002 at 01:43 UTC | |
by I0 (Priest) on Mar 28, 2002 at 02:12 UTC | |
|