use Encode; # ... treat $output2 as an output file, then: $output2 = decode( "utf8", $output2 ); # assuming that STDOUT is set to utf8 mode, you can now safely print "$output2\n";