看板 Perl 關於我們 聯絡資訊
※ 引述《gecer (gecer)》之銘言: : https://perldoc.perl.org/List/Util.html : $result = reduce { BLOCK } @list : 常看到 perldoc 提到 "BLOCK" 請問是什麼意思? 基本上就是一段以大括號包起來的程式碼,大致上來說在 perl 文件中常看到的 例子有: map BLOCK LIST # perldoc -f map grep BLOCK LIST # perldoc -f grep if (EXPR) BLOCK # perldoc perlsyn 把文件中的 "BLOCK" 這個字換成 "{ ... }" 或許就比較好理解 map { ... } LIST grep { ... } LIST if (EXPR) { ... } List::Util 文件當中的表示法略有出入,不過大致上不失原意。 可再參考此處說明: https://perldoc.perl.org/perlsyn.html#Basic-BLOCKs 由於以大括號包住,所以其中的區域變數的有效範圍就限於 BLOCK 當中。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.147.252.210 ※ 文章網址: https://www.ptt.cc/bbs/Perl/M.1520612900.A.5D7.html