On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> snip
> > my $rec = '';
> > while (<>) {
> >     if (/\\$/) { #if line is a continuation
> >         chop; #remove the continuation character
> >         $rec .= $_;
> >         next;
> >     }
> >     my @rec = split ' ', $rec;
> >     $rec = '';
> >     #do stuff with @rec
> > }
> snip
>
> Whoops, left out a chomp after the while.  The chop won't work
> correctly without it.
>

A better idea:


my $rec = '';
while (<>) {
   if (/(.*)\\$/) { #if line is a continuation
       $rec .= $1;
       next;
   }
   my @rec = split ' ', $rec;
   $rec = '';
   #do stuff with @rec
}


Bugger, this code drops the line after a record.  It needs a "$rec .=
$_" after the if.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to