#!/usr/local/bin/perl -w use strict; my @files =qw(CQA_frobbish.OUTPUT cQa_blintz.output cqA_pmos_lkg.output); my $ModNameList = 'pmos_lkg'; foreach my $file ( @files ) { if($file =~ m/.output/gi ) { my $name = $file; $name =~ s/.output//gi; $name =~ s/^cqa_//gi; if($ModNameList =~ m/$name/g) { print "Found:$name\n"; } } } #### Found:pmos_lkg #### use strict; foreach (@files){ my $name2; if(($name2) = / ^cqa_ # Starts with cqa_ (.*) # Here's the namestring we want \.output # and the right file extenstion $/xi # and nothing else. and $ModNameList =~ /$name2/){ print "FOUND: $name2\n"}}