因此,我用我所想看到的一系列具体话来做。 排 定 的 会 议
#!/usr/bin/perl
#use strict;
use warnings;
my @words;
my @triggers=(" [kK]ill"," [Aa]ssault", " [rR]ap[ie]"," [dD]rug");
my %hash;
sub count_words {
print "
";
}
my $word_regex
= qr{ ( # start a capture
p{Alpha}+ # any sequence of one or more alpha characters
(?: # begin grouping of
[ -] # allow hyphenated words and contractions
p{Alpha}+ # which must be followed by an alpha
)* # any number of times
) # end capture
}x;
my @files;
my $dirname = "/home/directory";
opendir(DIR,$dirname) or die "can t opendir $dirname: $!";
while (defined($file = readdir(DIR))) {
push @files, "$dirname$file";
} # do something with "$dirname/$file" }
closedir(DIR);
my @interestingfiles;
foreach $file (@files){
open FILE, ("<$file") or die "No file";
foreach $line (<FILE>){
foreach $trigger (@triggers){
if($line =~ /$trigger/g){
push @interestingfiles, "$file
";
}
}
}
close FILE;
}
print @interestingfiles;