in reply to Re^3: finding the absolute path to a module, from the module's, perspective
in thread finding the absolute path to a module, from the module's, perspective
This is pretty weird, but I think I've figured it out;
doing a,
inside my module will return something like:print __FILE__;
/lib/Stuff/Template.pmFile::Spec has a method called, file_name_is_absolute(), which basically on Unix, looks for a '/' as the first character ->
sub file_name_is_absolute { my ($self,$file) = @_; return scalar($file =~ m:^/:s); }
File::Spec will consult this method before it tries to piece together a absolute path; thus, File::Spec isn't even attempting to make an absolute path from the information from __FILE__
The workaround I've done is simply to hack the first, '/' off.
Changing my FOO.pm to something like:
Will print:package FOO; use File::Spec; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(bar); sub bar { print __FILE__; print '<p>'; print File::Spec->rel2abs(__FILE__) . "\n"; } 1;
lib/FOO.pm
/usr/home/user/www/cgi-bin/lib/FOO.pm
So, it doesn't look like it's *really* File::Spec's fault, but what would cause Perl to put a '/' at the beginning of the path in my module?
Hmm...
-justin simoni
!skazat!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: finding the absolute path to a module, from the module's, perspective
by ysth (Canon) on Sep 12, 2004 at 06:55 UTC |