I needed to convert a DOS file to UNIX line endings, on Windows with Activestate Perl 5.8.7. And all of a sudden, something we've all been doing for years without even thinking about it seems broken.
perl -i.bak -pe "s/\r//g" file
doesn't work anymore, nor do any usual or unusal variants of it.
What's up? I suspect the new perlio stuff to be the source of this problem, but I don't know how to solve this.
Have tried plenty of variants, but none worked. If I try to get rid of the \x0D, it stays in the file. If I remove \x0A, both \x0D and \x0A are removed.
Other (ever sillier) variants I tried:
perl -i.bak -pe "s/\x0D\x0A/\x0A/g" file
perl -i.bak -pe "BEGIN{binmode STDOUT}; s/\x0D\x0A/\x0A/g" file
Even this stupid line (aggravated by Win32's stupid shell) doesn't work:
perl -i.bak -ne "BEGIN{binmode STDOUT}; chomp; print qq{$_\x0A};" file
Please, enlighten me. What happened to my loved Perl? Is doing simple things becoming difficult? Do I have to go back to good old Perl 5.4?
2005-10-13 Retitled by g0n, as per Monastery guidelines
Original title: 'Perl line endings: something broken in 5.8?'
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |