> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 9:34 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: RE: newlines
> 
> 
> 
> This is the program; 
> 
> format ILL =
> @<<<<<<   
> $number
> ..
> open (INPUT_FILE, "$DATA_DIR/opacrequests.LN.out")  || die 
> "Cannot open
> $DATA_DIR/opacrequests.LN.out: $!";
> open (ILL, ">$OUT_DIR/pobk_rpt.txt") || die "Cannot open
> $OUT_DIR/pobk_rpt.txt: $!";
> while ($_=<INPUT_FILE>) {
> chop $_ ; 
> ($number, $date_time, $patron_name, $patron_barcode, 
> $address, $field6,
> $field7, $author, $title, $place, $publisher, $edition, $date) = split
> /\t/,$_;
> write (ILL);
> }
> 
> but as the textfile I'm reading in from has the format; 
> 
> first line of text
> (blank line)
> second line of text
> 
> when I write to the new textfile taking the content from the original
> textfile it's still including the blank line when I don't want it to.
>  
> Can you change a delimiter?

Yes, you can. The input record separator is $/ (see perldoc perlvar).

Or, you can just skip blank lines as part of your loop:

   while (<>) {
      next if /^$/;         # skip a blank line
   }

Or, you can test whether split() found anything:

   while (<>) {
      ($foo, $bar, $baz) = split(/\t/) or next;
   }

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

Reply via email to