I'm sorry for typos
i have a log file like this:
mynum[85295365] | yournum[3201410] | mymessage[4 ????? 4 off] | MSGLen[1]
i would coloring output like this
mynum == foreground blue
yournum == foreground yellow
and mymessage == foreground green.
i have a problem for coloring mymessage.
I tried the following code:
if($currentLine=~m/mymessage\[([\w+\d+\S]+){1,}\]/){
$mymessage=$1;
$outM="$mymessage";
$currentLine=~s/mymessage\[([\w+\d+\S]+){1,}\]/mymessage[$cg$outM$crs]/g;}
and no result did not.
help me :(((((
use the Term::ANSIColor CPAN module. It allows you to color screen output using ANSI escape sequences
Use this regex:
mymessage\[(.+?)\]
Then your code becomes:
if ($currentLine =~ /mymessage\[(.+?)\]/) {
$mymessage = $1;
$outM = $mymessage;
$currentLine =~ s/mymessage\[(.+?)\]/mymessage[$cg$outM$crs]/g;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.