可能有人親切地指出我爲什麼這個片段不編譯:編譯錯誤而定義的變量範圍
my $crond = "/etc/init.d/crond";
if(-e $crond) {
my $d = "d";
}
my $crond = "/etc/init.d/cron$d";
錯誤:
"my" variable $crond masks earlier declaration in same scope at /home/andrew/sandbox/processes2cron.pl line 27.
Global symbol "$d" requires explicit package name at /home/andrew/sandbox/processes2cron.pl line 27.
我試圖與「我的」,但還是範圍不同變化被不正確地定義。謝謝。
你可以說['使用診斷;'](http://perldoc.perl.org/diagnostics.html)產生更詳細的警告/錯誤 –