Christopher Fuchs wrote:
> Hello All:
>
> I have a perl script on UNIX which works properly for an ASCII
> input data file which is in the form of:
>
> record 1 line 1
> record 1 line 2
> record 1 line 3^M
> record 2 line 1
> etc
>
> The record delimiter is ^M (which is sometimes refered to as CR or \r).
> When run on a Windows box, the ^M is stripped away and as a result
> the program fails.  I've tried all combinations of character strings for $/
> without sucess.
>
> How do I get Perl/Windows to keep the ^M so I can parse this?

I doubt if the character is being 'stripped away', but you must find
what is delimiting this record.

I assume you are using the standard

  open FH, 'file' or die $!;

  while (<FH>) {
    :
  }

If you aren't already, you should add

  binmode FH;

before you read from the handle.

After that you will get /exactly/ what is in the file.

If it isn't too big, you might try

  undef $/;
  my $file = <FH>;

so that you can preocess the data as you wish,
but ultimately you need to find out what data
is in there - either through Perl or using
a binary editor, or something else.

The solution depends on the precise content, including
borh the normal record termination characters and those
of the rogue record which is giving you trouble.

Rob





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

Reply via email to