Harry Putnam <[EMAIL PROTECTED]> wrote:
: 
: Where is this pesky newline coming from?
: 
:    if(    $collect_lines 
:       && /^( +Folder:| Subject: |From |Message-[Ii][Dd])/){
:       push @chunk,$_;
:    }
:    if(/^START/){
:       $cnthits++;
:       $collect_lines = '';
:       @rev_chunk = reverse @chunk;
:       print "<@rev_chunk> <@chunk>\n";
: --->  @chunk = '';

    Should be:

        @chunk = ();

:       $str = join("\n",@rev_chunk);
:       push @pre_out, "$str" ;
:       $str = @rev_chunk = '';
:    }
:    last if($cnthits == ($count));
: }
: @out = reverse @pre_out;

    It comes from three lines. Before the
first pass, @chunk is not defined. The
first message is scanned and pushed onto
this empty array.

    After the first message, @chunk is
defined as an array with a single element
of ''. Subsequent lines are pushed on top
of this array and then a join is used to
add "\n" to each element including the ''.

    Since you're adding all those newlines
back in, why take them out in the first
place?


my @out;
my @chunk;

while ( <PROC> ) {

    if ( /^STOP/ .. /^START/ ) {

        push @chunk, $_ if /^ +Folder:| Subject: |From
|Message-[Ii][Dd]/;

        if ( /^START/ ) {
            push @out, join '', reverse @chunk;
            @chunk = ();
        }
    }

    last if @out == $count;
}

print "$_-- \n" foreach reverse @out;



HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to