http://qs321.pair.com?node_id=340636

Melly has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monkees,

What's the best way to read a particular line from a file? e.g. I want to perform a regex against line 10 of a file, but I don't want/need to read in the whole file.

my $line2 = (<FILE>)[9];
works, but I'm not sure how efficient this is. I could run a loop, but that would look messy, and if I want, say, line 5000, it would be inefficient (IMHO).

Any advice?

Tom Melly, tom@tomandlu.co.uk