my @fileformats = ('\\.avi','\\.mpg','\\.mpeg','\\.bin'); ... if($file =~ m/($fileformat)$/){$check=1; last;} #$string =~ m/Bill Clinton$/; else{$check=0;}