Re: [問題] 請問使用檔案比對時?
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)
→
03/11 18:14, , 1F
03/11 18:14, 1F
討論串 (同標題文章)