http://qs1969.pair.com?node_id=11138557


in reply to replacing close-single-quote with apostrophe

You can use the \x notation in a regex:
s/\xe2\x80\x99/'/g

If you want to use it in a one-liner, you need to be careful about quoting. In bash, for example, you need to write

perl -pe 's/\xe2\x80\x99/'\''/g' file

or use the \x for the single quote, as well:

perl -pe 's/\xe2\x80\x99/\x27/g' file

Alternatively, if you want to use "smart quote" directly:

use utf8;

open my $in, '<:encoding(UTF-8)', 'file' or die $!;
while (<$in>) {
    s/’/'/g;
    print;
}

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]