Saturday, 31 December 2022

How to get the absolute path of running perl script?


Method1:
 
use File::Basename;
my $dirname = dirname(__FILE__);

Method2:
 
use Cwd 'abs_path';
print abs_path($0);

Method3:
 
if ENV is defined then
$ENV{SCRIPT};

Labels: , , , , ,