John W. Krahn wrote:
Peter Daum wrote:
Unfortunately, this leads right to the next problem:
I also need "binmode" to turn off cr/lf conversion on DOS;
with "while (<>)" I don't know where to do this anymore,
because AFAIK, this has to be done after open, but before
the 1st I/O; now before the "while" the file hasn't been
opened yet, after the while it is already too late ... ;-)
Have a look at the open pragma:
perldoc open
... I didn't want to use it for the problem at hand because I
wanted to stay compatible with older versions of perl;
For curiosity, I meanwhile tried whether this would be a more elegant
solution for the future; Unfortunately, it doesn't look like this
allows to globally set the default eol handling for a whole program:
As far as I can see, with
use open IO => ':crlf';
CR/LF translation is turned on for all input
(so it would indeed solve my original problem).
As far as output is concerned, this pragma obviously only affects
explicitly opened output files, but not STDOUT
(which needs a separate "binmode STDOUT, ':crlf';")
Regards,
Peter
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/