How do I get the full path to a Perl script that is executing?

后端 未结 23 3036
情深已故
情深已故 2020-11-28 19:29

I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script $0 va

23条回答
  •  没有蜡笔的小新
    2020-11-28 19:50

    I think the module you're looking for is FindBin:

    #!/usr/bin/perl
    use FindBin;
    
    $0 = "stealth";
    print "The actual path to this is: $FindBin::Bin/$FindBin::Script\n";
    

提交回复
热议问题