in reply to Pick up specific file name

Hello JobyJ,

Welcome to the monastery. Why don't you try something like this? You can read more for module File::Find::Rule.

#!usr/bin/perl use strict; use warnings; use File::Find::Rule; sub get_files { my @dirs = ('/path1/path1', '/path2/path2'); # add more my $level = shift // 2; # level to dig into my @files = File::Find::Rule->file() ->name('*D602BG') ->maxdepth($level) ->in(@dirs); return @files; } my @files = get_files();

After that you can create a foreach loop on the files that you have returned. ;)

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Replies are listed 'Best First'.
Re^2: Pick up specific file name
by Laurent_R (Canon) on Jul 07, 2017 at 17:51 UTC
    Sure, you can do that. But, in such a simple case, why not simply use glob with the appropriate pattern? Something like this:
    my @files = glob ("$dir/*_0828900840_*D602BG");
    Update: this had already been suggested by choroba, sorry for duplication.