20220401_note.txt 20220303_page.txt 20220101_page_with_blanks.txt 20220111_page_blanks.txt #### These are the words to match on all the file names I am trying to get: ... my @get = qw(note page page_with_blanks page_blanks); # I have a sub to process them as they get read from a directory, code not complete but to show where the issue is: sub get_count { my $dir = 'data'; my $match = join '|',@get; # Doing a for loop here to match according to the values in $match now: my @files = glob "$dir/*.txt"; for my $file (sort @files) { # $match only gets the file names with "page" and ignores "page_with_blanks" and "page_blank". # How could I match all the file names and the ones has "page" only, also the other variations? if ($file =~ /^\bdata\b\/($year\d{4})_($match)/g) { my $date = $1; my $name = $2; print "D:$date - N:$name\n"; # It would print: #D: 20220401 - N:note.txt #D: 20220303 - N:page.txt #D: 20220101 - N:page_with_blanks.txt #D: 20220111 - N:page_blanks.txt }}