As tripleee mentioned, a program may consist of multiple
__FILE__
s.The
$0
may be set to anything (depends on the OS):$0 = "foo bar";
Instead of using rel2abs
, you might be interested in the FindBin
module, especially the $FindBin::RealBin
variable.