作者s1106 (big john)
看板Perl
標題[問題] 開檔問題
時間Sat Oct 24 10:03:04 2009
新手問題~
#check read file is ok
unless (open(INFILE, "/var/log/123.txt")) {
die ("cannot open file");
請問一下如果開檔失敗,要如何把路徑檔名顯示在螢幕上讓user知道
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 192.156.198.62
1F:推 godman362:把檔名當成參數紀錄,當錯誤的時候用參數顯示 10/24 12:32
2F:→ godman362:這樣的方法覺得如何? 10/24 12:32
3F:推 yanganto:open(INFILE, $file) || die "cannot open $file\a\n" 10/24 16:21
4F:→ s1106:還可以這樣用啊~感恩~ 10/25 23:21