in reply to Check If 2 Arrays Match

Not tested, but fairly straightforward. This assumes that the exact string represented by $ID shows up somewhere within the filename that you want to match.
use strict; use warnings; chomp(@ID); foreach my $ID(@ID) { foreach my $file (@files){ if ($ID=~ /$file/) { print "$file\n"; #if the matches are unique, you can bail this foreach after a ma +tch last; } } }