home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / perl / nutshell / ch3 / getline < prev    next >
Encoding:
Text File  |  1992-10-18  |  357 b   |  21 lines

  1. #!/usr/bin/perl
  2.  
  3. # get a line, combining continuation lines
  4. #  that start with whitespace
  5. sub get_line {
  6.     $thisline = defined($lookahead) ? $lookahead : <STDIN>;
  7.     line: while ($lookahead = <STDIN>) {
  8.         if ($lookahead =~ /^[ \t]/) {
  9.             $thisline .= $lookahead;
  10.         }
  11.         else {
  12.             last line;
  13.         }
  14.     }
  15.     $thisline;
  16. }
  17.  
  18. while ($_ = &get_line()) {
  19.     # Your code here.
  20. }
  21.