a proper solution would of course have to dynamically construct the correct character set depending on the language being selected.
A simpler solution might be
foreach $from (keys %{ $Lang{$L}{"Repl"} }) { $to=$Lang{$L}{"Repl"}{$from}; utf8::upgrade($from); # Use Unicode semantics for \b s/\b$from\b/$to/i; }
He's already assuming $from doesn't contains symbols since he's not using quotemeta, so using \b doesn't introduce any limitations.
My solution will also make "MÄR" work, unlike the current implementation and your proposed solution.
Update: Shoot! \w includes digits, so \b won't do. There's a POSIX class that includes just letters that does the trick:
utf8::upgrade($from); # Use Unicode semantics s/(^|[^[:alpha:]])$from($|[^[:alpha:]])/$1$to$2/i;
Update: As discovered below, what needs to be upgraded is the string on which s/// acts.
utf8::upgrade($_); # Use Unicode semantics s/(^|[^[:alpha:]])$from($|[^[:alpha:]])/$1$to$2/i;
In reply to Re^3: Date::Manip and German months names (solved)
by ikegami
in thread Date::Manip and German months names
by almut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |