use Foo::Foo1::Foo2::FooPackageName; my $file = "file.txt"; my $path = $INC{"Foo/Foo1/Foo2/FooPackageName.pm"}; $path =~ s/FooPackageName.pm/$file/; print "Full path to $file: $path \n";