- 755 名前:デフォルトの名無しさん mailto:sage [2008/11/14(金) 21:24:33 ]
- #!/usr/bin/perl
sub slurp { local ($/, @ARGV) = (wantarray ? $/ : undef, @_); return <ARGV>; } my $keyword_file = "list.txt"; my $target_file = "test.txt"; my @keywords = slurp($keyword_file); my $regex = join "|", map { chomp; "\Q$_\E" } @keywords; $regex = qr/$regex/; open my $fh, "<", $target_file; for my $line (<$fh>) { print $line if $line =~ $regex; } close $fh;
|

|