in reply to Removing blank lines from array
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Removing blank lines from array
by fundflow (Chaplain) on Feb 28, 2002 at 18:54 UTC | |
by Chmrr (Vicar) on Feb 28, 2002 at 19:00 UTC | |
|
Re: Re: Removing blank lines from array
by Jemts (Monk) on Feb 28, 2002 at 19:18 UTC | |
by Sweeper (Pilgrim) on Feb 28, 2002 at 20:47 UTC | |
by Aighearach (Initiate) on Mar 01, 2002 at 01:09 UTC | |
by jjohn (Beadle) on Mar 02, 2002 at 01:36 UTC |