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

In reply to Re: How to read every 16 line of file ? by monk2b
in thread How to read every 16 line of file ? by bh_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.