auto_w has asked for the wisdom of the Perl Monks concerning the following question:
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/; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: highlighting match found
by keszler (Priest) on Dec 17, 2011 at 20:25 UTC | |
|
Re: highlighting match found
by moritz (Cardinal) on Dec 17, 2011 at 20:53 UTC | |
|
Re: highlighting match found
by ww (Archbishop) on Dec 17, 2011 at 21:46 UTC | |
|
Re: highlighting match found
by roboticus (Chancellor) on Dec 18, 2011 at 02:31 UTC | |
|
Re: highlighting match found
by TJPride (Pilgrim) on Dec 17, 2011 at 21:18 UTC | |
by auto_w (Novice) on Dec 17, 2011 at 21:33 UTC | |
by TJPride (Pilgrim) on Dec 17, 2011 at 21:39 UTC |