> =head1 IMPLENTATION
>
> No idea, but should be straight forward.
I think the reason this hasn't been done before it because it's *not*
quite straightforward.
The way tr/// works is that a 256-byte table is constructed at compile
time that say for each input character what output character is
produced. Then when it's time to apply the tr/// to a string, Perl
iterates over the string one character at a time, looks up each
character in the table, and replaces it with the corresponding
character from the table.
With tr///e, you would have to generate the table at run-time.
This would suggest that you want the same sorts of optimizations that
Perl applies when it encounters a regex that contains variables:
1. Perl should examine the strings to see if they have changed
since the last time it executed the code
2. It should rebuild the tables only if the strings changed
3. There should be a /o modifier that promises Perl that the
variables will never change.
The implementation could be analogous to the way m/.../o is
implemented, with two separate op nodes: One that tells Perl
'construct the tables' and one that tells Perl 'transform the
string'. The 'construct the tables' node would remove itself from the
op tree if it saw that the tr//o modifier was used.