看板 Perl 關於我們 聯絡資訊
open(IF, "patterns.txt") or die "cannot open: $!"; chomp(@patterns = <IF>); close IF; open(IF, "data.txt") or die "cannot open: $!"; map {$line = $_; print $line if(grep {$line =~ s/$_/<NP>/} @patterns);} <IF>; close IF; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.29.131 參考下面改的 囧rz open(IF, "patterns.txt") or die "cannot open: $!"; $pattern = join('|', map { chomp; $_; } <IF>); close IF; open(IF, "data.txt") or die "cannot open: $!"; print grep { s/$pattern/<NP>/g } <IF>; close IF; ※ 編輯: david220 來自: 140.112.29.131 (03/11 17:06)
Yaowei:先感謝大家 小弟好好研究一下^^ 03/11 18:14