Perl Monk, Perl Meditation | |
PerlMonks |
Re: how to print first 5 lines of a fileby CharlesClarkson (Curate) |
on Nov 01, 2001 at 03:42 UTC ( [id://122455]=note: print w/replies, xml ) | Need Help?? |
Or, if you're certain there are at least five lines: print scalar <> for 1 .. 5;Calling the diamond operator <> in scalar context will return 1 line, assuming $/ is set to "\n". (Note - 'while' calls in scalar context while 'foreach' and 'for' call in list context.) HTH, Charles K. Clarkson
In Section
Seekers of Perl Wisdom
|
|