I'm trying to call a function from a package that has the same name with another package in different directory, and the functions are the same name also.
let's say that i have
I will suggest you to name the packages based on the directories (for eg
Dir2::Package1) on which they are; and keep them into same base (/lib in this case) directory:
/lib-- | ---/Dir1-- | | | --Dir1::Package1 | | ---/Dir2-- | -- Dir2::Package1
Then in the script you can fully qualify the subroutine name to call from those packages according to your wish:
#!/usr/bin/perl use strict; use warnings; use lib qw(./lib); use Dir1::Package1; use Dir2::Package1; # call from Dir1 Package1 Dir1::Package1::fun(); # call from Dir2 Package1 Dir2::Package1::fun();