I presume you want to skip the first line right? Thats what the
next until $. >1;
is supposed to do? Except it doesnt. :-) until != unless. Also it isnt the best way to remove the first line, as it puts a conditional inside a loop that need not be.

Then you have a problem with

next if $_ = /^done/;
which is exactly equivelent to
next if $_= $_=~/^done/;
Which isnt what you want at all. In addition I question whether that should really be last and not next. So I would say it should be
last if /^done/; #or #last if $_=~/^done/;
But by the time I get to this point I reckon that you are trying to put all but the first and the (ostensibly) last record in the file into an array, skipping blank lines. If so I would write it as
my @contents; my $header=<PAST>; # extract the first line while (<PAST>) { next unless /\S/; # ignore whitespace only lines. last if /^done/; # finish when we hit a line starting with 'done +' #chomp; # uncomment if you dont want newlines in conten +ts. push @contents,$_; # add the line to the buffer }
UPDATE:

Assuming that the done line also contains a count then you may want to check that it matches with

my @contents; my $header=<PAST>; # extract the first line while (<PAST>) { next unless /\S/; # ignore whitespace only lines. if (/^done,(\d+)$/) { die "Count mismatch in trailer. Got $1 expected @{[scalar @con +tents]}" unless $1 == scalar(@contents); last; } #chomp; # uncomment if you dont want newlines in conten +ts. push @contents,$_; # add the line to the buffer }
HTH

--- demerphq
my friends call me, usually because I'm late....


In reply to Re: term in last line of flatfile by demerphq
in thread term in last line of flatfile by alexiskb

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.