Q:

Perl: substitute .* to §

I have to substitute multiple substrings from expressions like $fn = '1./(4.*z.^2-1)' in Perl (v5.24.1@Win10):  
$fn =~ s/.\//_/g;
$fn =~ s/.\*/§/g;
$fn =~ s/.\^/^/g;

but § is not working; I get a ┬º in the expression result (1_(4┬ºz^2-1)). I need this for folder and file names and it worked fine in Matlab@Win10 with fn = strrep(fn, '.*', '§'). 
How can a get the § in the Perl substitution result?  

A:

It works for me:
#! /usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use utf8;
use open IO => ':encoding(UTF-8)', ':std';

my $fn = '1./(4.*z.^2-1)';

s/.\//_/g,
s/.\*/§/g,
s/.\^/^/g
    for $fn;

say $fn;

Output:
1_(4§z^2-1)

You can see use utf8, it tells Perl the source code is in UTF-8. Make sure you save the source as UTF-8, then.
The use open sets the UTF-8 encoding for standard input and output. Make sure the terminal to which you print is configured to work in UTF-8, too.

