FAQ

On Wed, 6 Feb 2002, Tanton Gibbs wrote:

You've run across the typical cross-platform issues that arise between Unix
and Windows. The problem is that Windows uses \r\n to terminate a line
while Unix just uses \n. When perl on unix sees \r it doesn't know what to
do because it only expects \n. Therefore, to correct the problem, you need
to change all \r\n to just \n. A typical way to do this is to run dos2unix
on the file. However, not all systems come with dos2unix. Therefore, you
can run

perl -e "while( <> ) { s/\r\n/\n/g; print; }" infile.txt > outfile.txt
A simpler way with Perl:

perl -pi -e 's/\cM//g' <file>

-- Brett
http://www.chapelperilous.net/
------------------------------------------------------------------------
Does a one-legged duck swim in a circle?

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 6 | next ›
Discussion Overview
groupbeginners @
categoriesperl
postedFeb 6, '02 at 10:17a
activeFeb 6, '02 at 11:01p
posts6
users6
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase