How to open a file from a perl module -
i have module called conf.pm , opens file called conf.json. conf.json relative path conf.pm ".../conf/conf.json";
but when include conf.pm in scripts in other folders relative path changes , conf.pm not find conf.json.
how can open conf.json conf.pm.
the trick here use module findbin
allows work 'relative location' in module.
in .pm
add:
use findbin; $home_path = $findbin::realbin; $json_path = $home_path."/../conf/conf.json";
Comments
Post a Comment