First, thanx to Tim and Bob.  It is working as I would like.  Now I have
a substitution question.

If $line is "delay=12, status=sent (fw-3.alliednational.com)" how do I
make a substitution like this...

#!/usr/bin/perl -w

use strict;

my $line;
my $red="\033[0;31m";
my $yellow="\033[0;33m";
my $blue="\033[0;34m";
my $normal="\033[0m";

while ( $line = <STDIN> ) {

        $line =~ s/reject/$red.reject.$normal/gi ;
        $line =~ s/ from /$yellow from $normal/gi ;
        $line =~ s/status/$blue status $normal/gi ;

        print $line;
}

What I get is "delay=12,  status =sent (fw-3.alliednational.com)" with
the word status in blue.  Is there a way to use the substitution strings
and not print the spaces?  As you can see I tried periods and it prints
the periods.  The "from" works becauase the string I want to search for
is literally "<space>from<space>".

Thanx!

-Michael



>>> Tim Yohn <[EMAIL PROTECTED]> 07/10/03 04:53PM >>>
On Thu, 2003-07-10 at 17:30, Michael Weber wrote:
> Here's the basic frame of code I'm using:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> my $line;
> 
> while(1) {
>         $line = <STDIN>;
>             # Highlighting code goes here...
>         print $line;
> }
> 

I would suggest using the following:

while($line = <STDIN>) {
        # Highlighting code goes here...
        print $line;
}

This way it sets $line each iteration through the loop and when there
is
no more <STDIN> to process it breaks the while and exits.

Tim.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to