#!/usr/bin/perl use strict; use warnings; use Encode; my $from = $ARGV[0]; my $to = $ARGV[1]; my $in_file = $ARGV[2]; my $out_file = $ARGV[3]; open my $input, "<", $in_file or die "$!"; open my $output, ">", $out_file or die "$!"; local $/ = undef; my($raw_octets,$perl_scalar,$utf8_octets); while($raw_octets = <$input>){ $perl_scalar = decode($from, $raw_octets); $utf8_octets = encode($to, $perl_scalar); print $output $utf8_octets; } close($input); close($output);