[Solved] Read file content and use Regular Expression to locate a pattern in each File in Perl


use strict;
use warnings;

use HTML::TreeBuilder::XPath;

my ($dir) = @ARGV;

my @files = glob "$dir/*";

for my $file (@files) {
  my $tree = HTML::TreeBuilder::XPath->new_from_file($file);
  my @opacity = $tree->findnodes_as_strings('//div[@class="opacity description"]');
  print "\n$file\n";
  print "  $_\n" for @opacity;
}

solved Read file content and use Regular Expression to locate a pattern in each File in Perl