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

Re: [MacPerl] use module in cwd




On Sat, 22 Jan 2000, Paul Schinder wrote:
> 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.

Thanks for the info.  Unfortunately, "require" didn't change things.
Neither did chdir() in a BEGIN block or saving as a droplet.


On Sat, 22 Jan 2000, Ronald J Kimball wrote:

> Would you mind telling us the contents of @INC and how you ran the
> script?

I would be happy to do this, in conjunction with the advice above.  I
ran the script by dropping it on the Perl icon, and selecting Run
"Get-CountrList.plx" from the menu.  I have also saved it as a
droplet, and run it by double-clicking.  Same result.  Here is the top of
my script, down to the line of failure:


#-------------- Begin script code -----------------

#!/usr/bin/perl   

sub BEGIN
{
    use Cwd;
    
    my $cwd = cwd();
    
    print "  Now printing cwd:\n";
    print "$cwd\n\n";
    chdir( $cwd) or die "Can't change to cwd: $!\n";
    
    print "  Now printing INC:\n";
    print (join "\n", @INC);
    print "\n\n";
}

require ParseCountryList;
   

#-----------  End script code -------------------


Here is the output:



-------------------------------------------
  Now printing cwd:
Annex:PowerWorld:Slurpie

  Now printing INC:
Annex:Development:MacPerl :site_perl:MacPPC:
Annex:Development:MacPerl :site_perl:
Annex:Development:MacPerl :ext:
Annex:Development:MacPerl :lib:MacPPC:
Annex:Development:MacPerl :lib:
Annex:Development:MacPerl :site_perl:MacPPC:
Annex:Development:MacPerl :site_perl:
:
Dev:Pseudo:

# No such file or directory.
File ':ParseCountryList.pm'; Line 23
-----------------------------------------


Now, at this point, you're probably thinking ParseCountryList.pm is not
in Annex:PowerWorld:Slurpie.  But it is.  I have previously added an
opendir and readdir on $cwd and ":", and printed the file list.
ParseCountryList.pm shows up in this list, as fine as you please.  I've
looked many times for some stupid typo, I've saved the file as a different
name and changed the name in the script.  They are sitting right beside
each other in the folder.  I have two other scripts, which like this one
used to work, like this one use/require another module in the current
directory, and like this one fail right now.

I just tried swapping the two AutoLoader.pm files, and as Paul Schinder
said, that didn't change the outcome.

Perhaps it's time to offer up a humble chicken sacrifice to the Perl gods,
who must be angry.  :)  



--
MattLangford 



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