Hi monks -simple question but i have difficulty finding it I have a script that looks for a match in a log file and once it's found it will display it --- now because i 'm looking for 3 parameters at the same time i need to highlight the matches found in red,green and blue so i can see where they are in a log file -so far i was unable to find this -but it's pretty easy to do with grep but not in perl--suggestions?
sub file_in_out { @ARGV == 3 || die "usage: $0 PATTERN LOGNAME DATE \n"; my ( $PAT, $LOG, $DATE ) = @ARGV; open (my $HAN, $LOG) || die "Cannot open '$LOG' because: $!"; #print "ENTRIES FOUND FOR PATTERN = $PAT, LOGFILE=$LOG, DATE=$DATE.... +.............\n"; while ( <$HAN>) { next unless /$DATE/; print "\n", "--------------------------------------------------------------- +--------------------------------------------------------\n", $_ if /$PAT/; }
In reply to highlighting match found by auto_w
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |