http://www.perlmonks.org?node_id=1012715


in reply to Using encoding

Add binmode $output; right after opening the CSV file for writing. For example:

use strict; use warnings; my $string = '£'; open my $output, '>:encoding(utf8)', 'out.txt' or die $!; binmode $output; print $output $string; close $output;

Contents of out.txt:

£

Contents of out.txt without binmode $output;:

£