in reply to Re^2: Format Streaming Text file with CR/LF
in thread Format Streaming Text file with CR/LF
In that case, I pretty much answered this question yesterday.
From a file handle:
binmode $fh_in; binmode $fh_out; local $/ = \90; while (<$fh_in>) { print $fh_out "$_\x0D\x0A"; }
From a string:
binmode $fh_out; while (length($str)) { my $rec = substr($str, 0, 90, ''); print $fh_out "$rec\x0D\x0A"; }
If you want CRLF when run on Windows and LF when run on other OSes, get rid of the binmode and replace \x0D\x0A with \n.
|
|---|