in reply to Do modules know the callers full path?
A combination of abs_path() and caller() works for me in one of my distributions:
use Cwd qw(abs_path); my $script_path = abs_path((caller())[1]); print "$script_path\n";
Here's a full working example:
Package.pm:
package Package; use strict; use warnings; use Cwd qw(abs_path); sub import { my $path = abs_path((caller())[1]); print "$path\n"; } 1;
Script:
use warnings; use strict; use lib '.'; use Package;
|
|---|