(I must be in my "dense" phase.)

Various VMS utilities generate text files, and occasionally embed a <CR><LF>
pair in the record itself, rather than simply writing two records. Typing
the file out is no big deal, but it's a little obnoxious to read inside of
an editor, for example, TPU.

Does anybody have a snippet of code lying around that would
  *  convert a record with embedded CR-LF pairs into multiple records, and
  *  simply pass through all others?

I've been playing around, and my code has no trouble *recognizing* a record
with embedded CR-LF(s). I just can't get a SPLIT to work right.

I've tried with /\0a\0d/, /\r\n/, and /[\r\n]+/.
I've tried with SPLIT in-line in the FOREACH list, and externally using a
list variable.

Assuming I have a valid file as input, what's wrong with

        while (<>) {
          chomp;
          if (! /[\r\n]/) { print $_, "\n";
          } else {
            chomp;
            foreach (split /[\r\n]+/) {
              print $_, "\n";
            }
          }
        }

SPLIT keeps returning a one-element list, and even with the "\n", then next
line read not containing a CR-LF pair is part of the previous record.

Thanks in advance....

Reply via email to