Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to read every 16 line of file ?

by monk2b (Pilgrim)
on May 13, 2011 at 15:27 UTC ( #904689=note: print w/replies, xml ) Need Help??


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

my $line_number = 16; my $count = 0; while(<DATA>){ chomp($_); $count++; next unless $count == $line_number; print "$_\n"; $count = 0; } __DATA__ 1 Bob 48 IT 2 David 26 IT 3 Jerry 22 IT 4 Josh 33 IT 5 Karl 35 IT 6 Dan 50 IT 7 Tom 26 IT 8 Randy 48 Engineering 9 Trevor 57 Engineering 10 Tony 48 Engineering 11 Larry 39 Engineering 12 Farhan 40 Engineering 13 Sandy 28 Engineering 14 Jessie 55 Engineering 15 Carl 25 Engineering 16 Donald 58 Engineering 17 Rick 44 Engineering 18 Barry 38 Engineering 19 Bruce 30 Engineering 20 Joe 37 Engineering 21 Mun 53 Engineering 22 Shiro 48 Engineering 23 Sally 50 HR 24 John 32 Finance
Perl Good - Manual process bad

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://904689]
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 2023-03-21 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (59 votes). Check out past polls.

    Notices?