I have about 200 files located in the same directory, all of which contain a specific piece of content that I need to match using RegExp and either save all of the matched contents into a single array or store them in a new file.
When working with notepad++ regexp engine I do the following to locate the pattern:
<div class="opacity description">(.*)</div>
so that is the pattern I am looking for.
And this is how i Open and List all the files in the directory.
my $d = shift;
opendir(D, "details/") || die "Can't opedir $d: $!
";
my @list = readdir(D);
closedir(D);
foreach my $f (@list) {
print "$f = $f
";
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…