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

Re: [MacPerl] MacPerl bugs?



At 6:46 AM -0700 6/2/99, Scott Prince wrote:
>on 6/2/99 7:44 AM, Chris Nandor wrote...
>>At 23.51 -0400 1999.06.01, Scott Prince wrote:
>>>$^O - I have a script and need to know if the platform is Mac or other:
>>>
>>>if ($^O =~ /mac/) { #.... }
>>># then later on...
>>>$z = eval {/$x/};
>>># but wait, eval no longer works!
>>># removing the ($^O =~ /mac/) verified this.
>>
>>/mac/ won't match $^O on MacPerl.  It might match some other OS's, like
>>machten.  $^O for MacPerl is "MacOS".

>laziness on my part, instead of checking what $^O returns for the mac,
>just matched on it. But how would that change eval? I should also have
>noted that both examples are saved as cgi's served up with Web Sharing.

But you can test things directly in MacPerl (or, as many of us are coming
to enjoy, you can work in BBEdit 5.1 with MacPerl integration).

Little snippets like:

#!perl -w

# just to check the line before the split,
# copy a line from your data and paste it here:
$_ = 'a	b	c			';  #thar's tabs in thar
print;    #in BBEdit's MacPerl Output window, you can see the tabs...
print '*',"\n";    #just to show end of line

tr/\t/\&/;   #substitute '&' for tab
print;
print"\n\n";

#now test the split on its own:

$line = "a\tb\tc\t\t\t\n";
@x = split (/\t/, $line);
print scalar @x, "\n";

__END__

yields:

a	b	c			*
a&b&c&&&

6

[snips]

>>It prints "6".
>
>Right you are. In this case the file is an uploaded file and it seems
>that it may be related to using cgi-lib.pl. Is CGI.pm a more compatible
>solution for this?

Hrm. First it's bugs in MacPerl, now cgi-lib.pl is suspect. Aim lower. ;-)

Regarding file uploads with cgi-lib.pl and CGI.pm:

I've done several sites for which my client or their users upload files
using Netscape's (now HTML 4's) <INPUT TYPE='file'...> widget. I've used
both cgi-lib.pl and CGI,pm for this with reliable results on UNIX servers.
Of course there has been improvement to both over their lifetimes, so check
your versions. For a time, the file upload always worked from my Mac but
was iffy from Windows machines.

One client uploads their used equipment inventory using this method, so
their staff won't have to deal with FTP. Their inventory is uploaded as a
tab-separated text file, each record a line similar to your example's data
line. Some lines have several tabs in a row, sometimes at the end of the
line, like yours. The upload is handled by cgi-lib.pl; it's worked fine for
almost two years. After upload, the data gets processed line by line in
some conditions, and by grep in others. In both cases, the tabs in the line
are significant to the processing, and I've never had a problem with
cgi-lib.pl dropping tabs...

I've shifted to using CGI.pm for many uses once handled by cgi-lib.pl. But
this has been because CGI.pm has many more features, and can be used in
object oriented programming mode. However, for what I take to be be your
interest, there might be a problem: I have heard that, perhaps until just
recently, file uploading doesn't work with CGI.pm in MacPerl...

Good luck!

- Bruce

# ~~~~~~~~~~~~~~~~~~~
# Bruce Van Allen
# bva@cruzio.com
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Director
# WireService, an Internet service bureau
# Serving the educational and nonprofit sectors
# wire@wireservice.org
# http://wireservice.org
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org