(Please put your code in <c>...</c> tags. It'll handle escaping the necessary character and it'll place the line breaks for you.)
There's a lot of needless work here. Perl code and regexs are being parsed and compiled over and over again. Also, there's no reason to use /o anymore. It does nothing more than complicate things.
my %chartran = ( "\xE1" => 'aacute', "\xE2" => 'acirc', "\xE4" => 'auml', "\xC0" => 'Agrave', "\xC1" => 'Aacute', ); my $re = '[' . (join '', keys %chartran) . ']'; $re = qr/$re/; while (<VRUN>) { s/($re)/$chartran{$1}/g; print; }
Of course, you could simply use core module HTML::Entities's encode_entities method.
use HTML::Entities qw( encode_entities ); while (<VRUN>) { print encode_entities($_); }
In reply to Re: large hash of regex substitution strings
by ikegami
in thread large hash of regex substitution strings
by scodes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |