If you had tested it with more input, you'd have found it is wrong.
You wrote:
foreach my $key (keys %convs) { $in =~ s/$convs{$key}/$key/g; }
The OP wrote:
And that *almost* works perfectly. Where it doesn't work is if there's two of these special characters grouped around a normal character... [...] And since I can get these in any order, there's no way to put them in an order that always works.
Since you stored the patterns as values in a hash, the order in which they're substituted gets randomized such that with the input you tested with, the code happens to work.
Makeshifts last the longest.
In reply to Re^2: Pattern Matching, left-to-right
by Aristotle
in thread Pattern Matching, left-to-right
by TrekNoid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |