Unsurprisingly, Randal's solution is on the nose for your question, but I thought I might talk about a related issue. Why are you reading in the whole file at once when you really only want the first 43 lines? This is very wasteful for large files. You might consider a more verbose while loop like the following:
print $html_preamble; # whatever's prolog to the real content open READ, $file or die "Oops! can't read $file: $!"; my $cnt = 0; while(my $line = <READ>){ last if $cnt >= 43; # do we count rejected lines? no. next unless $line =~ /\w/; # lines with visible content print $line; $cnt++; } close READ; print $html_footer;
I understand your code is doing some pagination, so the above code is only a sketch of the solution, but I think this solution is a bit easier to maintain and handles large files better.
cheers!
Edit ar0n -- switched <pre> tags to <code>
In reply to Re: Removing blank lines from array
by jjohn
in thread Removing blank lines from array
by Jemts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |