On Jan 27, 2004, at 8:55 PM, Trina Espinoza wrote:

So this may be wishful thinking, but I would be kicking myself later if I didn't ask. Is there a function in perl where you give
the function exact line numbers and it would only read the data in the range of lines you gave it? My other alternative would be
using a counter to find a start line and an end line in a file. Doable but painful. Let me know if there is any hope . . .

Will a variable do, instead of a subroutine? ;) $. holds the current line number. If we combine that with a little range operator magic, we get a pretty simple solution to your problem. See if this one-liner helps you along:


perl -ne 'next unless ($. == 1) .. ($. == 5); print' YOUR_FILE_HERE

Good luck.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to