我知道文件名可以在perl腳本中變量。是否同樣適用於cgi-perl腳本。因爲當我在open語句中使用變量時,出現錯誤No這樣的文件或目錄。但是,當我直接提到文件打開閱讀的路徑。這些變量是從窗體傳遞的。值正確傳遞它們不是空的(通過打印可變參數進行檢查)。可以目錄名稱和文件名是cgi perl腳本中的變量
實施例:
$dir=abc;
$file=file1;
open (FILE, '/var/www/cgi-bin/$dir/$file')
or print "file cannot be opened $!\n";
錯誤:
file cannot be opened no such file or directory
。
這有效。我可以知道爲什麼單個qoutes不起作用嗎? – Nagaraju
@Raju:因爲單引號內的變量不是插值。請參閱http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators – Toto