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

Re: [MacPerl] use module in cwd



At 2:21 AM -0600 1/22/00, Matthew Langford wrote:
>I can't get this to work:
>
>use Foo;
>
>where Foo.pm is in the same directory as the script with that line.  The
>error given:
>    # No such file or directory.
>    File ':Foo.pm'; Line 23
>
>Would this work if it were File 'Foo.pm'?

It may work if you just change "use" to "require".

"use" worked for me with some test scripts.  The trouble is MacPerl 
is sometimes looking at a directory other than the one you think it 
is, and so it doesn't find what you think is there.  Remember that 
"use' happens at compile time, while "require" happens at run time. 
To make sure you're in the right directory, put a chdir to the 
directory you want in a BEGIN block at the beginning of your script, 
before the "use".  Alternatively, a safe way is to save the script as 
a droplet in the same directory as Foo.pm, and then double click on 
the droplet to run the script.

I am, of course, using the Autoloader in site_perl.  That Autoloader 
was fixed to find the autosplit.ix files. If you don't, things break. 
But I think that this is a chimera, since MacPerl was using 
Autoloader only because it couldn't find the file in @INC.

>
>This used to work, until I "fixed" my @INC to put site_perl ahead of the
>built-ins (lib, specifically).  Interestingly, the Autoloader.pm in
>site_perl which is giving up the search has a bit more Mac-specific code
>than the older one which worked the way I want.  I would give version
>numbers, except--who woulda thot?--there are no version numbers in
>Autoloader.pm!  Why would a Core Thing not have a version?  (IMO, unless a
>module will not or cannot be changed, it should have a version number.)
>
>--
>MattLangford

--
Paul Schinder
schinder@pobox.com

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