in reply to reading a random line from a file

If you have to pick a random line from the file many times over the FAQ answer is not very good as it would require reading the file once for each pick. If the file is big enough that slurping it isn't desirable, then using the second method BrowserUk suggested makes a lot of sense.

I'd probably use Tie::File though. It would be easier and likely almost if not just as efficient because Dominus went to some length to make it fast.

#!/usr/bin/perl -w use strict; use Tie::File; my @lines; my $o = tie @lines, 'Tie::File', 'somefile.txt' or die $!; print "$lines[rand @lines]\n" for 1..10;
-sauoq
"My two cents aren't worth a dime.";