in reply to how to get the full array value if part of the element matches

use strict; use warnings; my $MATCH_THIS = q(aa); my @filenames = qw(file1:aa file2:bb file3:cc file4:AA); for my $fn (@filenames) { print "Matched $fn\n" if $fn =~ /$MATCH_THIS/i; }
prints:
Matched file1:aa Matched file4:AA
However, from the word 'In' in your post, I get the feeling that you want to grep the content of the files named aa, bb etc. That's not the case, is it?

Update: Added "the content of" for clarification.
Update: Changed @array to @filenames.