$check ="ABCD" # this value will come from an array # ... $var = substr($file_name, 0, 3); # ... if($var eq $check){