#Script tests matching of IDs with a list of filenames #Should find matches without being too greedy #For testing input is given as two arrays, defined within the script #Input will be a a list of IDs in a text file and a scan of a directory containing the image files # # use strict; use warnings; my @dir = ("I C 17.jpg", "I C 17 a.jpg", "I C 17 a,b -A x.jpg", "I C 170.jpg", "I C 171 a,b -A x.jpg", "I C 171 a,b -B x.jpg"); my @ids = ("I C 17", "I C 171"); foreach my $a (@ids) { my $ext = "[^0-9]*\.jpg"; my $a_ext=$a.$ext; foreach my $b (@dir) { if ($b =~ m/($a_ext)/) { print "Found file: $b\n"; } } }