Skip to content

Commit 1e50e0e

Browse files
載入檔案的運算符
1 parent bb41e64 commit 1e50e0e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

require.pl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//2019, 12/28, by Queenie Chen
2+
// require 可保障只讀入一次
3+
4+
// 適用情境
5+
//當 QQQ.pm 為了共用任務,本身已經載入 PPP.pm 模組
6+
//因而使得 PPP.pm 在程式中被載入兩次
7+
//第一次 perl 直接讀進該檔案。
8+
//然後在 QQQ.pm 中又再次處理同一檔案
9+
//再次定義 PPP
10+
// 可能會被警告著其副常式被重新定義
11+
12+
require 'QQQ.pm';
13+
require 'PPP.pm'
14+
15+
// require 運算符號追蹤了 Perl 已讀入哪些文件
16+
// 倘若已經讀取過,就會忽略後續對同一檔案 require 的操作
17+
// 檔案的最後一個運算式必須回傳回真值,如1,讓require知道執行成功
18+
// 倘若載入的檔案中有語法錯誤,會自動以 die 中斷執行,無須寫很多 die $@ if $@

0 commit comments

Comments
 (0)