If the header line appears somewhere in the middle of the file, you could make use of a state variable (here $in_data_section). You'd initialize the variable to false, and set it to true as soon as you enconter the header line. And only when $in_data_section is true, you'd treat the input lines as data (numbers)...

(Similarly, if you can tell what ends your data section, you could then reset the state variable to false...)

... my $in_data_section = 0; while (<FILE>){ chomp; if ($in_data_section) { my @numbers = split; #... } $in_data_section = 1 if m/^Number/; }

Alternatively, if you know that there are exactly two data lines following the header, you could also do something like

while (<FILE>){ chomp; if (/^Number/) { # found header, now we're expecting two lines with numbers for (1..2) { $_ = <FILE>; chomp; my @numbers = split; #... } } #... do other stuff }

In reply to Re^3: printing column info without headers by almut
in thread printing column info without headers by annie06

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.