for my $encoding_candidate (qw(iso-8859-1 UTF-8)) { eval { $sCodepoints = decode( $encoding_candidate, $sLine, Encode::FB_CROAK ) }; if ( $@ ) { # input was not $encoding_candidate print "> Not $encoding_candidate\n"; #$sCodepoints = $sLine; } }