open $fh, '<', 'd:\input.txt' or die 'Could not open file'; $encoding = get_encoding_from_filehandle($fh);