in reply to Re^2: Substitute some Unicodes with their escapes
in thread Substitute some Unicodes with their escapes

As noted before, you don't need to encode each character. Also, you can build a regex that matches all the keys of the hash, than you don't need to call any subroutine from /e. This way, you only replace the characters you know how to replace, so it will work even for the $ which is ASCII 36.
my $chars = join "", keys %_table; sub escapeUTF8 # Now needs a better name! { my ( $sgml_r) = @_; $$sgml_r =~ s/([\Q$chars\E])/$_table{$1}/g; }

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

Replies are listed 'Best First'.
Re^4: Substitute some Unicodes with their escapes
by jjmoka (Beadle) on Jun 09, 2020 at 14:54 UTC
    That's a good spot. Thanks