On Thursday 04 September 2008, Maxim Veksler wrote:
> On Thu, Sep 4, 2008 at 4:17 PM, Shlomi Fish <[EMAIL PROTECTED]> wrote:
> > Here's a Proof-of-Concept script I wrote to implement this:
> >
[snipped]
>
> I mainly write in Python / Java but the above work from Shlomi is just
> great !This is exactly what I've been after, quick dirty and works.
>
> Thanks a-lot !!
>

You're welcome.

> Shlomi and Amos -- You are the man's ;)

Thanks.

>
>
> // OT Note: I must admit that to some one who is accustomed to logic... the
> above code is completely unreadable. Could someone please explain where in
> the above code the ANSI module / method / operator / what ever they do in
> Perl... is called to the actually coloring that was read from stdin?

Yes. The key line is:

<<<
$l =~ s/($re)/colored($1, $c)/eg;
>>>

$re is a variable containing a regular expression. s/($re)/EXPR()/eg matches 
all occurences of $re (while capturing it as $1) and replaces them with 
EXPR(). The expression in our case is:

<<<
colored($1, $c)
>>>

It and returns a string that represents $1 coloured using the colour $c.

As you should note, I assign $re and $c previously here:

<<<
        my $re = $pat->{pat};
        my $c = $pat->{color};
>>>

Regards,

        Shlomi Fish

-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Rethinking CPAN - http://xrl.us/bjn7p

Shlomi, so what are you working on? Working on a new wiki about unit testing 
fortunes in freecell? -- Ran Eilam

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

  • Re: Co... Moish
    • R... Maxim Veksler
    • R... Yaacov Fenster - System Engineering Troubleshooting and other stuff
  • Re: Co... Amos Shapira
    • R... Maxim Veksler
      • ... Amos Shapira
        • ... Amos Shapira
          • ... Shlomi Fish
            • ... Maxim Veksler
              • ... Shlomi Fish
      • ... Tzafrir Cohen
        • ... Amos Shapira
          • ... Tzafrir Cohen
            • ... Maxim Veksler
              • ... Amos Shapira
          • ... Maxim Veksler
            • ... Amos Shapira
  • Re: Co... Yedidyah Bar-David

Reply via email to