看板 Perl 關於我們 聯絡資訊
※ 引述《s1106 (big john)》之銘言: : 寫了一個從檔案讀取2.txt的字元來建立目錄如下: : #!/usr/bin/perl -w : unless (open(INFILE, "2.txt")) { : die ("cannot open input file file:$^E\n"); : } : $line=<INFILE>; : while ($line ne "") { : mkdir ($line) or warn "Cannot opendir :$^E\n"; : $line=<INFILE>; : } : -------------------------------------------------- : 當我執行時 ,Cannot opendir :檔案名稱、目錄名稱或磁碟區標籤語法錯誤。 : 有人可以告訴我哪裡錯了嗎? 個人猜測應該是沒有過濾掉檔案中的 \n 或是 \r 字元。 根據上述的錯誤訊息,判斷應該是 Win32 環境下。 建議參考文章 http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx 說明哪些範圍的字元是允許的。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.64.130
s1106:謝謝你的提示,原來加個chomp就能解決 11/04 13:30
cutecpu:推 11/05 12:54