我有一个文件夹,其中包含“n”个 html 文件。我将阅读文件并采取一行。(即)我将<img />
标签放在一个数组中并打印该数组。现在不打印数组。你能帮助我吗。我的代码在这里。
use strict;
use File::Basename;
use File::Path;
use File::Copy;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
print "Welcome to PERL program\n";
#print "\n\tProcessing...\n";
my $foldername = $ARGV[0];
opendir(DIR,$foldername) or die("Cannot open the input folder for reading\n");
my (@htmlfiles) = grep/\.html?$/i, readdir(DIR);
closedir(DIR);
@htmlfiles = grep!/(?:index|chapdesc|listdesc|listreview|addform|addform_all|pattern)\.html?$/i,@htmlfiles;
# print "HTML file is @htmlfiles";
my %fileimages;
my $search_for = 'img';
my $htmlstr;
for my $files (@htmlfiles)
{
if(-e "$foldername\\$files")
{
open(HTML, "$foldername\\$files") or die("Cannot open the html files '$files' for reading");
local undef $/;my $htmlstr=<HTML>;
close(HTML);
$fileimages{uc($2)}=[$1,$files] while($htmlstr =~/<img id="([^"]*)" src="\.\/images\/[^t][^\/<>]*\/([^\.]+\.jpg)"/gi);
}
}
在命令提示符下。
perl findtext.pl "C:\viji\htmlfiles"
问候,维吉