in reply to How do I pick a random line from a file?
Another more obvious way, but possibly memory intensive
way would be to read the entire file into an array and
then pick a random element.
open FILE, "<$file" or die "Could not open $file: $!\n"; @array=<FILE>; close FILE; $randomline=$array[rand @array];
|
---|
In Section
Seekers of Perl Wisdom