#!/usr/bin/perl -w use strict; use File::BOM qw( :all ); open_bom(FH, "test.txt", 'bytes'); my $encoding = get_encoding_from_filehandle(FH); print $encoding . "\n\n";