I'm trying to use something like File::Find::Rule to get rid of some code that has the UNIX find command in it.
Working code:
sub AllInFilesystemResults {
my ($class) = shift;
my ($collectArchive) = shift;
my @searchLocations;
if ( $collectArchive =~ /^archive/ ) {
@searchLocations = "/vol/$collectArchive/prod/*";
}
else {
@searchLocations = (
"/vol/archive*/prod/*/$collectArchive/*",
"/vol/archive*/prod/system/archive/$collectArchive/*"
);
}
my %listOfFilesDatabase;
foreach my $searchLocation (@searchLocations) {
my @archivesInFilesystem =
`find $searchLocation -type f 2> /dev/null
| grep -v \"\/archive\/archive\/\"`;
chomp @archivesInFilesystem;
$searchLocation = qr/$searchLocation/;
foreach my $locationFS (@archivesInFilesystem) {
print "$locationFS\n";
utf8::decode($locationFS);
$listOfFilesDatabase{$locationFS}++;
}
}
return %listOfFilesDatabase;
}
I would like @searchLocations to be regex that then gets searched through
if ( $collectArchive =~ /^archive/ ) {
@searchLocations = "/vol/$collectArchive/prod/.+";
}
else {
@searchLocations = (
"/vol/archive\\d{2}/prod/.+/$collectArchive/.+",
"/vol/archive\\d{2}/prod/system/archive/$collectArchive/.+"
);
}
my %listOfFilesDatabase;
foreach my $searchLocation (@searchLocations) {
$searchLocations = qw/$searchLocation/;