On Mon, 2002-07-22 at 19:15, David T-G wrote:
> Desmond --
>
> ...and then Desmond Lee said...
> %
> ...
> % A sample from the file looks like this:
> %
> % while ( $row = $db->sql_fetchrow($result) );^M
> % $db->sql_freeresult($result);^M^M $total_threads =
> % count($threadrow);^M }^M else^M {^M
> % message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);^M }^M}^M//
> % END THREADED MOD CODE^M^M^M# ^M#-
>
> Did you get this from a Mac, by chance? I see ctrl-M in there but no
> line breaks except what I'll bet a Twinkie your mail program put in for
> you. For delightful historical reasons, ASCII end-of-line is
>
> \r on Mac
> \n on UNIX
> \r\n on DOS (== Win)
This is true in C, but only sort of true in Perl. In Perl \n is equal
to whatever the local line terminator is. So when a Perl script is run
under the Mac OS (this is possibly different in Mac OS X) \n is equal to
\13; when the same Perl script is run in a Unix style environment \n is
equal to \10; and when the Perl script is run under CPM/DOS/MS Windows
\n is equal to \13\10.
>
> So it looks like you want something like
>
> perl -pi.bak -e 's/\r/\n/g' moby_threads_install.txt
>
> to change returns to newlines (rather than just stripping out returns by
> newlines -- because there aren't any newlines!
This will work for the current case (converting from a Mac to Unix on a
Unix box), but won't work for the other cases.
perl -pi.bak -e 's/(\13\10|\13|\10)/\n/g' moby_threads_install.txt
Should convert from any style to the current style (even Unix to Unix).
>
> %
> %
> % Thanks
> %
> % Desmond
>
>
> HTH & HAND
>
> :-D
> --
> David T-G * It's easier to fight for one's principles
> (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie
> (work) [EMAIL PROTECTED]
> http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
>
--
Today is Prickle-Prickle the 58th day of Confusion in the YOLD 3168
Hail Eris, Hack Linux!
Missile Address: 33:48:3.521N 84:23:34.786W
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]