Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to read every 16 line of file ?

by LanX (Sage)
on May 13, 2011 at 14:01 UTC ( #904676=note: print w/replies, xml ) Need Help??


in reply to How to read every 16 line of file ?

I think what you want is reading 16 lines in a gulp not every 16th line.

Cheers Rolf

UPDATE:

more explicit:

while ( @lines = readlines($filehandle,16) ) { print @lines,"----\n"; } sub readlines { my ($fh, $count) = @_; my @gulp; while (<$fh>) { push @gulp,$_; last unless --$count; } return @gulp; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://904676]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2022-08-16 04:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?