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
}

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


Reply via email to