use File::BOM; open(IN,"< d:\\input.txt"); ($encoding, $spillage) = get_encoding_from_filehandle(HANDLE); close IN;