foreach $W (@tableList){ foreach $Q (@fileList){ if($Q =~ /$W/i){ print TABLE "$W\n"; push(@tableUsed, $W); print USED $W; }#end of if else{ print USED "no tables exist in the file\n"; } } }#end of foreach loop