Reputation: 3171
my @hex_locations = ("$FindBin::Bin/../../../project/platform-fsm9900_cdp-full/build-target/gnss-1.0.0",
"$FindBin::Bin/../../../project/platform-fsm9900_cdp-base/build-target/gnss-1.0.0");
instead of these 2 lines, can I specify it in single line with a wildcard as below? "$FindBin::Bin/../../../project/platform-fsm9900_cdp-*/build-target/gnss-1.0.0"
my @hex_dep_files;
sub find_dep_files {
my $F = $File::Find::name;
if ($F =~ /.d$/ ) {
push(@hex_dep_files,$F)
}
}
for my $loc (@hex_locations) {
find({ wanted => \&find_dep_files, no_chdir=>1}, $loc);
}
with above for loop, I am getting all the *.d files from the @hex_locations, can I do it in single function instead of calling a separate function called "find_dep_files", I don't want to call a different function from this for loop so I need not define the array @hex_dep_files as global.
Thanks for all the help.
Upvotes: 1
Views: 1257
Reputation: 386386
To answer the actual question.
my @hex_dep_files;
for my $loc (@hex_locations) {
find({
no_chdir => 1,
wanted => sub {
my $F = $File::Find::name;
return if $F !~ /.d$/;
push @hex_dep_files, $F;
},
}, $loc);
}
or
my @hex_dep_files;
find({
no_chdir => 1,
wanted => sub {
my $F = $File::Find::name;
return if $F !~ /.d$/;
push @hex_dep_files, $F;
},
}, @hex_locations);
Upvotes: 2