可能重複:
In Perl, how do I get the directory or path of the current executing code?在Perl中,是否有一個關鍵字表示當前源文件所在的目錄?
不是當前的工作目錄,但在源被解釋的目錄在
在PHP它的__DIR__
關鍵字。 Perl是否有這樣的事情?
可能重複:
In Perl, how do I get the directory or path of the current executing code?在Perl中,是否有一個關鍵字表示當前源文件所在的目錄?
不是當前的工作目錄,但在源被解釋的目錄在
在PHP它的__DIR__
關鍵字。 Perl是否有這樣的事情?
有幾個不同的來源。您可以嘗試$ ENV {密碼},或者使用CWD模塊:
use Cwd;
my $cwd = getcwd;
當前工作目錄與源文件目錄不同。 –
特別是在mod_perl.So這個答案是不正確的。 –
http://www.perlmonks.org/?node_id=47035 –
@米奇小麥:鏈接到更適用的http:// perlmonks.org/?node=47035 – ysth
沒有人擁有正確的答案。正確的答案是'使用File :: Findbin qw($ Bin)'。您的腳本安裝目錄現在位於'$ Bin'中。有可能以嚴肅的意圖欺騙這個,但它對大多數情況都適用。 – tchrist