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

Re: [MacPerl] MacPerl bugs?



on 6/2/99 4:38 PM, Ronald J Kimball wrote...
>On Wed, Jun 02, 1999 at 09:46:50AM -0400, Scott Prince wrote:
>> Actually I believe I used a case insensitive match:
>> if ($^O =~ /mac/i)
>> 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.

>It wouldn't change eval.

>> >I wonder what version you have?  Using the 5.2.0r4 (the latest), I try:
>> >
>> >  $_ = "a\tb\tc\t\t\t\n"; # read in from a database file
>> >  @x = split (/\t/, $_);
>> >  print scalar @x;
>> >
>> >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?
>
>Neither cgi-lib.pl nor CGI.pm will have any effect on builtin functions
>such as split().
>
>Are you sure that the string ends with a newline when you split it?  If
>your string is more like "a\tb\tc\t\t\t", then you _will_ get 3, because
>split() drops trailing null fields by default.

Thats it! I was about to give it up. With MacPerl...

$x = "a\tb\t\t\t\n";
chomp $x;
@x = split (/\t/, $x);
foreach $f (@x) { $count++; }
print "$count\n\n";
exit;

I lose the empties, on Unix (example below) they are retained. Why should 
this be different for Unix?

Should have posted the original code to begin with, but couldn't remember 
which script it was from at the time...

while (<TEMP>)
{
$in_count++;
$item_number++;
@item_num = ("$item_number");
$line = $_;
chomp $line;
@fields = split (/\t/, $line);
$fields[3] = &format_date("month yyyy","$fields[3]","yyyymm");
    # checking only the first record
    if (!($field_check))
    {
        foreach $fc (@fields) { $number_of_fields_read++; }
        if ($number_of_fields_read != $required_number_o_import_fields)
        {
        # error stuff...
        }
    $field_check = '1';
    }
        
>> I have been attempting to have one cgi script that will run on Mac or 
>> Unix by changing only one line in the script. Maybe that's asking too 
>> much, but I love my Mac and hate the Unix text editors. It would be nice 
>> to have one subroutine that would handle all the little quirks; flock, 
>> file sys delimiters, \r\n, etc.
>
>I think that's asking too little.  You should be able to run it without
>changing any lines at all!
>
>Ronald
>


Scott


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