in reply to Getting perl file path from Function

Yes, modules are preferable. Code like:

require 'test.pl';
shocks me back to the mid 1990s, Perl 4-style, about fifteen years behind the curve. For both modules and your old style require 'test.pl', try dumping the %INC hash. For example:
use strict; use warnings; use Data::Dumper; require 'test.pl'; # old style use MyTest; # module (preferred) print Dumper(\%INC); # show PATHs of all files loaded via do, use, r +equire
See also the core FindBin module.