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

Re: [MacPerl] FW: Uploading problem with Mac



At 23.16 -0500 1998.11.05, Walter Torres wrote:
>I am forwarding this from the Win 32 list.
>
>Any one have any ideas?

>require "d:/web/wwwroot/abrhs/scripts/cgi-lib.pl";

Try instead:

use CGI qw(:cgi-lib);

The rest might just work now.  My _guess_ is that cgi-lib handles newlines
wrong.

Oops, in fact, I have confirmed it.  cgi-lib.pl is broken.  These lines are
wrong:

      while (($lpos = index($buf, "\r\n\r\n")) == -1) {
      @heads = split("\r\n", $head);

... as is every other line that prints \n to STDOUT.  See perlport.pod for
more information (included with perl5.005, also available on the web and on
CPAN).  BTW, if you want to use cgi-lib.pl and not CGI.pm, edit cgi-lib.pl
thusly:

  change every \n that is printing to STDOUT, or splitting data as in the
while and split lines above, to \012

  change every \r that is printing to STDOUT, or splitting data as in the
while and split lines above, to \015

That should fix the problem.

In other words, dies and error strings can contain \n (and SHOULD contain
\n), but reading and writing to sockets should NEVER contain \n or \r in
platform-independent code.  Those "characters" are not only
platform-inspecific, but can be different even on the same platform in
different situations.  For sockets, \r\n is wrong.  Instead, the
unambiguous \015\012 or \x0D\x0A or even \cM\cJ must be used.


And, you still have path problems, of course:

>open (UPLOAD, ">d:/web/wwwroot/abrhs/data/$real_name") || die "Can't

Macs use : as the delimiter, not /.  Again, see perlport.pod for more info.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch