I did a perl script that searches for files, but I want to enhance this perl script so that it does a more indepth/advance search.
E.g., I have log files, and the log file names are typically, e.g., LogFileName2.0.0.20030715.box1.csv. I did a search script that'll find any log file, but I want it to also search by the boxname, the version and the date.
In the script I did, I have this. Can someone explain how to setup this up for an advance search. Thanks.
### GET FILES
$itec = 0;
foreach $item (@searchcrit)
{
if (-e "$item"
{
opendir(DIR,"$item"
@files = readdir(DIR);
closedir (DIR);
$fnc = 0;
foreach $fn (@files)
{
$files[$fnc] = "$item/$fn" . "\t" . "$weburls[$itec]/$fn";
$fnc++;
}
}
else
{
print "Error - $item does not exist.";
}
$itec++;
$tmpc = push(@allfiles,@files);
}
### SORT FILES
$sc = 0;
foreach $item (@allfiles)
{
foreach $ext (@searchext)
{
if ($ext eq substr($item, length($item) - length($ext), length($ext)))
{
$sfiles[$sc] = $item;
$sc++;
}
}
}
E.g., I have log files, and the log file names are typically, e.g., LogFileName2.0.0.20030715.box1.csv. I did a search script that'll find any log file, but I want it to also search by the boxname, the version and the date.
In the script I did, I have this. Can someone explain how to setup this up for an advance search. Thanks.
### GET FILES
$itec = 0;
foreach $item (@searchcrit)
{
if (-e "$item"
{
opendir(DIR,"$item"
@files = readdir(DIR);
closedir (DIR);
$fnc = 0;
foreach $fn (@files)
{
$files[$fnc] = "$item/$fn" . "\t" . "$weburls[$itec]/$fn";
$fnc++;
}
}
else
{
print "Error - $item does not exist.";
}
$itec++;
$tmpc = push(@allfiles,@files);
}
### SORT FILES
$sc = 0;
foreach $item (@allfiles)
{
foreach $ext (@searchext)
{
if ($ext eq substr($item, length($item) - length($ext), length($ext)))
{
$sfiles[$sc] = $item;
$sc++;
}
}
}