Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Shooting at a Moving Target

by belg4mit (Prior)
on Feb 14, 2007 at 02:33 UTC ( #599842=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Shooting at a Moving Target
Select or Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://599842]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-11-23 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (127 votes), past polls