At 17:30 +1200 2001.04.02, Andrew Duncan wrote:
>I joined this list while I was fooling with my first OSX perl script, and hit
>the same problem. Actually it was the line endings in the data I was filtering
>(a comma-delimited file), rather than the script.
>
>I toyed with setting the end-of-record separator ($/) in the script, but
>in the
>end I just did this:
>
> cat ~/data.txt | tr "\r" "\n" > /tmp/data.txt
> mv /tmp/data.txt ~/data.txt
>
>Later I put that in a shell script.
Since this is a Perl list:
perl -pi.bak -e 's/\r/\n/g' data.txt
Creates data.txt, and backs up old file as data.txt.bak. If you don't want
a backup, just do:
perl -pi -e 's/\r/\n/g' data.txt
Note that on Mac OS 9 the values of \r and \n are switched. So the above
one-liner will convert a Unix script to Mac OS (Classic) format when run on
Mac OS 9, and vice versa when run on Unix (or Mac OS X). :-)
--
Chris Nandor [EMAIL PROTECTED] http://pudge.net/
Open Source Development Network [EMAIL PROTECTED] http://osdn.com/