O
Oliver Heidelbach
Hi,
is there any way to get Unix Perl to work on DOS files (CRLF) when
reading in paragraphs and without to convert the line endings
before processing the file?
The usual
$/ = "";
@paras = split(/""/,$_);
works fine for DOS files on systems with DOS format and DOS-aware
Perl and for Unix files on Unix systems and Unix-aware Perl.
However, it does not work for DOS files on Unix systems. I tried
everything which came to my mind, but nothing really works.
e.g.:
$/ = "^\r*$";
@paras = split(/"^\r*$"/,$_);
$/ = "^\r\n$";
@paras = split(/"^\r\n"/,$_);
$/ = "^\s*$";
@paras = split(/"^\s*$"/,$_);
I am regularly shifting DOS formatted files to Unix for
further processing and having to convert those before
touching with Perl is a major annoyance.
If the paragraph separation cannot be done on that format
on Unix properly, is there any easy way to slurp in the file,
convert it in memory and then process the data as if it were
read from a file directly?
Thanks for any help with this.
Mit freundlichen Gruessen
Oliver Heidelbach
is there any way to get Unix Perl to work on DOS files (CRLF) when
reading in paragraphs and without to convert the line endings
before processing the file?
The usual
$/ = "";
@paras = split(/""/,$_);
works fine for DOS files on systems with DOS format and DOS-aware
Perl and for Unix files on Unix systems and Unix-aware Perl.
However, it does not work for DOS files on Unix systems. I tried
everything which came to my mind, but nothing really works.
e.g.:
$/ = "^\r*$";
@paras = split(/"^\r*$"/,$_);
$/ = "^\r\n$";
@paras = split(/"^\r\n"/,$_);
$/ = "^\s*$";
@paras = split(/"^\s*$"/,$_);
I am regularly shifting DOS formatted files to Unix for
further processing and having to convert those before
touching with Perl is a major annoyance.
If the paragraph separation cannot be done on that format
on Unix properly, is there any easy way to slurp in the file,
convert it in memory and then process the data as if it were
read from a file directly?
Thanks for any help with this.
Mit freundlichen Gruessen
Oliver Heidelbach