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

[MacPerl] Re: lib and referances



At 07.46 -0500 1999.12.07, Paul Schinder wrote:
>At 11:32 PM -0800 12/6/99, Nicholas G. Thornton wrote:
>>use File::Basename;
>>$dir = &dirname($INC{'Time.pm'});
>>$dir .= 'beginning.txt';
>>open FILE, "<$dir" or die "can't open '$dir' for input";
>>
>>yields
>>
>># can't open ':beginning.txt' for input.
>
>
>Do you "use Time" in your script?  %INC doesn't automatically get
>loaded with every possible module, only with the ones you're using.
>Try this:
>
>use File::Basename;
>$dir = dirname($INC{'File/Basename.pm'}); #the one you're *sure* you're using
>etc.
>
>And yes, it's a /, even under MacPerl.

And not to drag this out any more than it has been, but if you have
cpan-mac or File::Spec installed, this is an all-platform solution:

#!/usr/bin/perl -wl
use File::Basename;
use File::Spec::Functions;
use Foo::Bar;

my $file = catfile( dirname($INC{'Foo/Bar.pm'}), 'beginning.txt' );

__END__

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

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