I have one folder it contain 'n' number of html files. I'll read the files and take the one line. (i.e) I'll take the <img />
tag in one array and print the array. Now doesn't print the array. Can you help me. My code is here.
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);
}
}
In command prompt.
perl findtext.pl "C:\viji\htmlfiles"
regards, viji