Just an observation...$1 is global, so you can't use it with 'my'. Also, remember that Encode::Detect::Detector
doesn't encode but only decodes, so your sub get_encoding should probably be "get_decoding".
Comment on Re: Encode::Detec::Detector: This is not an SV reference error