http://www.perlmonks.org?node_id=599842


in reply to Shooting at a Moving Target

(Pseudo-code) evilness using experimental regexp features might look like:
$TABLE='a'; #or whatever the default set is s/(?:\x1B([abcs])(?{$TABLE=$^N}))?(.)/${$TABLE}{$2}/e
To simplify your table you could expand the RHS to include an ||$2.

Mmmm symbolic references.

UPDATE: You could of course "legitimize" that and use $TABLES{$TABLE}->{$2}

--
In Bob We Trust, All Others Bring Data.

Replies are listed 'Best First'.
Re^2: Shooting at a Moving Target
by Aristotle (Chancellor) on Feb 14, 2007 at 02:55 UTC
    my $char_for = $codepoint_table{ 'a' }; s{ \x1B ([abcs]) | (.) }{ $1 ? do { $char_for = $codepoint_table{ $1 }; '' } : $char_for->{ +$2 } }ge;

    Makeshifts last the longest.

      But where's the evil?! (You also didn't use the "requested" (?{). TIMTOWTDI

      --
      In Bob We Trust, All Others Bring Data.