We don't bite newbies here... much | |
PerlMonks |
lima1's scratchpadby lima1 (Curate) |
on Jul 25, 2007 at 18:27 UTC ( [id://628757]=scratchpad: print w/replies, xml ) | Need Help?? |
When 100% Code Coverage Backfires PBP's .perltidyrc file, was Re: Perl Best Practices last hour of cb Title: How do I skip the first $n lines of a file efficiently? Question: Suppose I want to read a file but I'm not interested in the first $n lines. What's the best way of skipping these first $n lines? Answer: To accomplish this task, one often sees code like this: The problem with this approach is that the test is performed on every single line of the file. Which is not necessary as we can do the skipping before the main while loop. The probably shortest and most efficient way to do that is: $. is the line counter of the current file handle. See perlvar. |
|