#!/usr/bin/env perl use strict; use warnings; use utf8; use Encode qw (:DEFAULT is_utf8); use Encode::CP924; # more encodings here, removed to save space my %encodings = ( CP924 => { name => "ibm-924_P100-1998", string => "\N{U+0000}\N{U+0001}\N{U+0002}[...]" }, #more encodings here, removed to save space ); foreach my $encoding ( sort keys %encodings ) { print "Current Encoding: $encoding - $encodings{$encoding}{'name'} \n"; my $utf8_decode = $encodings{$encoding}{'string'}; my $encoded_output; eval { $encoded_output = encode( $encodings{$encoding}{'name'}, $utf8_decode ); }; # filecontent is encoded from utf-8 to current encoding if ( $@ ){ print $@,"skipping encoding\n"; next; } open ( my $fh_out, '>', $encoding ) or die; print $fh_out $encoded_output; close $fh_out; }