[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] MacPerl cgi-script question



> $string =~ s/\n/<br>/g;

> It works fine on UNIX, but not with MacPerl.
> Specifics says that "\n" on a Mac does not have the same
> ASCII number as "\n" on UNIX, and that might be the
> problem here. Anyway, can anyone tell me what that piece
> of code should look like on a Mac?

You might try \r instead of \n on the theory that if \n
which is LF on Unix is mapped to CR on the Mac (because
the Mac standard is to use CR betwen lines) then the
logical map for \r which is CR on Unix would be LF on
the Mac.  At least this is what most Mac C compilers do...

I wonder if \012 would work.  Or, is there a way to do
something like:

ifdef Macintosh
  lf = '\r'
else
  lf = '\n'
endif

then, in the code

$string =~ s/{lf}/<br>/g;

(I'm doing first class hand-waving here, but Perl is such a
capable language that I'd just bet it could be done this way!
Lord only knows the syntax though...)


+-+-+
Charles B. (Ben) Cranston <zben@ni.umd.edu>
http://www.wam.umd.edu/~zben