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

Re: [MacPerl] MacPerl5 and libwww-perl-5b7




John_Peterson@byu.edu writes:
} On Tue, 12 Mar 1996, Brad Cox wrote:
} 
} > use HTTP::Date;
} > $time = time;
} > my $stringGMT = time2str($time);
} > $nutime = str2time($stringGMT) || die "failed on $stringGMT\n";
} > print "$stringGMT $time/$nutime\n";
} > 
} > and got...
} > 
} > # failed on Wed, 13 Mar 1996 01:24:54 GMT
} 
} (...boy, I'm chatty today...)
} 
} It's been discussed recently on this list (and someone correct if I 
} remember wrong--I'm to lazy to go back and look) that 'my' doesn't work 
} correctly outside of subroutines in MacPerl.  I don't believe this has 
} been fixed yet (well, there's some confusion about what 'my' should 
} do outside of a block)--even in the latest MacPerl rev.  Try it without 
} the 'my.'

Yes, it's probably the my bug, but no, removing the my from the main routine
doesn't help.  Here's the way the my bug works.  Suppose you're
require'ing or use'ing a package that looks something like this:

package nVIR;  #considering the recent Usenet thread...

my $MerryXMas = "I am a virus";

sub foo { #don't know any other Mac virus names :-(
        return $MerryXMas;
}

Now if your main routine looks like:

use nVIR;

$bar = foo();

print "$bar\n";

you'll find that you get "I am a virus" in Unix Perl and nothing in
MacPerl, because, while MacPerl sets $MerryXMas when it steps through
during the "use", it promptly forgets about it after it returns to the
main routine.  So when it reenters the package in the subroutine call,
it has no idea what $MerryXMas is.

LWP uses this method of initializing variables constantly, so if you
just use a routine without fixing it, you'll get all sorts of nulls
returned to you in places where you might expect to get something.
That's almost certainly what happens here.

I sent Brad Cox my working-under-MacPerl version of libwww-perl-5b6.
I'm willing to send it to anyone who wants it, and if I get enough
requests for it, I'll put it on mors.  I haven't done that in the past
for two reasons.  First, most of the changes are required by the
MacPerl bug and aren't due to lurking Unixisms.  There are a lot of
changes, and I certainly might have missed something.  Second, the
author I've corresponed with, Gisle Aas, is doing a good job of trying
to make the code portable to all sorts of platforms, including Macs.
He intends that the code in CPAN should work on Macs with little to no
changes.  Save for the my bug and a few leftovers (and the fact that
LWP5b9 now uses Net::FTP, which is Unixcentric), my opinion after a
cursory look is that large sections of libwww-perl-5b9 would work under
MacPerl as is.  The big obstacle is that 5b9 "require 5.002;".

} 
} John Peterson -- University Networking Services -- Brigham Young University
} Internet: John_Peterson@byu.edu                       Phone: (801) 378-5007
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us