On 7/11/07, jeniffer <[EMAIL PROTECTED]> wrote:

I have a file of the format
action arg1 \
          arg2 \
          arg3 \

action2 arg1 \
          arg2 \
          arg3 \

In other words, some of the file's "lines" are more than a single line
each; a continued line ends with a backslash. Perl can handle this:

 my $current_line = "";
 while (<FILE>) {
   chomp;
   $current_line .= $_;
   if ($current_line =~ s#\\\Z##) { # remove trailing backslash
     next; # don't process it yet
   } else {
     # It's not continued any further
     &do_whatever($current_line);
     $current_line = "";
   }
 }
 warn "Unexpected end of file?" if $current_line;

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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


Reply via email to