Please correct me, but how is this better than abs_path($0) ?
Because it answers the OP's question... "Is there a way to get a module to return the full system path of the script using the module?"
$ cat lib/Foo/Bar.pm package Foo::Bar; use warnings; use strict; use Cwd qw/abs_path/; sub foo { my $callerfile = (caller)[1]; print "DEBUG: caller=<$callerfile> \$0=<$0>\n"; return abs_path($callerfile); } 1; $ cat y.pl use warnings; use strict; use Foo::Bar; print Foo::Bar::foo(), "\n"; $ cat x.pl use warnings; use strict; do './y.pl'; $ perl -Ilib x.pl DEBUG: caller=<./y.pl> $0=<x.pl> /tmp/y.pl
In reply to Re^5: Do modules know the callers full path?
by haukex
in thread Do modules know the callers full path?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |