Skip to content

Commit 92ce751

Browse files
接受字串運算式作為參數
1 parent c4a5cc3 commit 92ce751

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

eval.pl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//eval
2+
//2019, 12/28, by Queenie Chen
3+
4+
//除了偵測錯誤外
5+
//evel 還能接受字串運算式作為參數
6+
//直到執行階段才編譯和執行字串內容
7+
//雖然好用但很危險
8+
//當字串內有不可靠資料的時候
9+
10+
11+
eval '$sum = 2 + 2';
12+
print " The sum is $sum\n";
13+
14+
15+
q $result = eval "2+2";
16+
print "the result is $result\n"

0 commit comments

Comments
 (0)