Assuming that the entries in the log file are ordered by time which is the case in your test data and that you only want to keep the last entry of a particular event, the following would work.
#!/usr/bin/perl -w use strict; my %log; foreach(<DATA>) { chomp; if(!/^$/){ /.+(EVENT\d)/; $log{$1} = $_; } } print map { "$log{$_}\n" } sort keys %log; __DATA__ 09:12:50:861 EVENT1 #Don't want this line 09:13:09:467 EVENT1 #Don't want this line 09:13:09:837 EVENT1 09:13:38:059 EVENT2 09:14:03:115 EVENT3 09:14:04:076 EVENT4 09:14:11:376 EVENT1 09:14:34:049 EVENT2 09:14:34:990 EVENT3 #Don't want this line 09:14:34:990 EVENT3 09:14:34:990 EVENT4
In reply to Re: Parsing Pattern Question
by arun_kom
in thread Parsing Pattern Question
by dlcasey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |