in reply to Re^4: Detect the Charset of an file
in thread Detect the Charset of an file

The problem is I can't post the whole script, because it's not allowed in our company.

You don't have to post the whole script, simply post something sequivalent that demonstrates the problem you encounter -- replicate the problem with fewer lines of code

So far its all been syntax errors

Here is what I "wrote" by copy/pasting from http://p3rl.org/Encode::Detect::Detector

#!/usr/bin/perl -- use strict; use warnings; use Encode::Detect::Detector; use autodie qw/ open /; my $octets = 'abc'.chr(266).chr(666); my $filename = shift || \$octets; open my($infh), '<:raw', $filename ; my $d = new Encode::Detect::Detector; while(my $line = readline $infh ){ $d -> handle( $line ); } $d -> eof; close $infh; my $charset = $d->getresult; print "**$filename gots *".$charset."*\n";
__END__ **SCALAR(0x3f8fac) gots *UTF-8* </c>