using wildcard in the dir locations and find all files with an extension

前端 未结 2 1937
庸人自扰
庸人自扰 2021-01-25 02:52
my @hex_locations = (\"$FindBin::Bin/../../../project/platform-fsm9900_cdp-full/build-target/gnss-1.0.0\",
                     \"$FindBin::Bin/../../../project/platform         


        
相关标签:
2条回答
  • 2021-01-25 03:39

    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);
    
    0 讨论(0)
  • 2021-01-25 03:45

    Can't you just use glob:

    my @files = </path/to/files/*.extension>;
    
    0 讨论(0)
提交回复
热议问题