jbrugger has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I want to check the encoding of a file, since i need to convert all my templates to utf8, but not the ones that are utf8, since they will be double encoded (using iconf)
However, after supersearching i came up with the following possible solution:
#!/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";
This is not returning anything however.
for now, we started to use (opening each file and parsing it in the encoder):
use Encode::Guess; my $decoder = guess_encoding($arg->{String}, 'latin1'); if (ref($decoder)) { return 0; } else { return 1; }
For the rest i did not find any other way of dertermining the encoding of a file, anyone knows what is wrong with File::BOM or does anyone have a better solution?
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.