in reply to term in last line of flatfile
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.next until $. >1;
Then you have a problem with
which is exactly equivelent tonext 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 benext 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 aslast if /^done/; #or #last if $_=~/^done/;
UPDATE: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 }
Assuming that the done line also contains a count then you may want to check that it matches with
HTHmy @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 }
--- demerphq
my friends call me, usually because I'm late....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: term in last line of flatfile
by alexiskb (Acolyte) on Oct 11, 2002 at 08:41 UTC |