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

Re: [MacPerl] How can you get runtimes to find modules loaded with'use' ?



John_Peterson@byu.edu wrote:
>On Thu, 14 Mar 1996 HARBAUGH@FCRFV2.NCIFCRF.GOV wrote:
>> The script runs under the macperl application, creating the DB file as
>> expected.  However, when I save the file as a runtime (setting the @INC
>> array by hand), I can't get the program to find the module files in the
>> lib directory with the 'use' command.  NOTE that the program *CAN* find
>> the modules with the 'require' command

>Well, if I'm not mistaken I think the problem is that 'use' files get 
>compiled and run at the moment it's encountered.  Here are some excerpts 
>from the pod's:
>
>Perl modules are included by saying 
>
>        use Module;
>
>This is exactly equivalent to 
>
>        BEGIN { require "Module.pm"; import Module; }
>
>...and...
>
>Because the use statement implies a BEGIN block, the importation of
>semantics happens at the moment the use statement is compiled, before the
>rest of the file is compiled. 

Hey, that was a brilliant insight! I was truly puzzled how require and use
would differ here.

>> PS: Is it possible to "save" the MacPerl application's library path
>>     in a runtime so that it doesn't have to be explicitely set within
>>     a script?

You can copy the "MacPerl Preferences" file to a file "xxx Preferences" if the
runtime is called "xxx".

Matthias

-----
Matthias Neeracher                                   neeri@iis.ethz.ch
   "These days, though, you have to be pretty technical before you can 
    even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_