rduke15 has asked for the wisdom of the Perl Monks concerning the following question:
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?'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl line endings: something broken in ActiveState Perl 5.8?
by jmcnamara (Monsignor) on Oct 13, 2005 at 08:20 UTC | |
by rduke15 (Beadle) on Oct 13, 2005 at 08:50 UTC | |
by Tortue (Scribe) on Oct 13, 2005 at 10:58 UTC | |
|
Re: Perl line endings: something broken in ActiveState Perl 5.8?
by Delusional (Beadle) on Oct 13, 2005 at 09:35 UTC | |
by snowhare (Friar) on Oct 13, 2005 at 11:45 UTC | |
|
Re: Perl line endings: something broken in ActiveState Perl 5.8?
by Skeeve (Parson) on Oct 13, 2005 at 07:17 UTC | |
by rduke15 (Beadle) on Oct 13, 2005 at 07:28 UTC | |
by Skeeve (Parson) on Oct 13, 2005 at 08:59 UTC |