#!/usr/bin/perl -w use strict; my %mylist; my $min; my $max; my $range; my $line; # get the range (in this throwtogether it must be entered # with no spaces in the form HHMMSSTT-HHMMSSTT) # Hour, Minute, Second, Tenths of seconds # Get the range $range = ; # Break up the range ($min, $max) = split /-/, $range; # Squeeze out leading and trailing spaces $min =~ s/^\s+//; $min =~ s/\s+$//; $max =~ s/^\s+//; $max =~ s/\s+$//; # Get the filenames and break into fields open(CAT, "cat mon402.log |"); (@ARGV = ) unless @ARGV; for (@ARGV) { if ($_ =~ m/(\d{2}\-\w{3}\-\d{4})\ (\d{2}\:\d{2}\:\d{2}\.\d{2})/) { # push the restricted range of filenames onto a hash of arrays # keyed on the date field if (($2>= $min) && ($2 <= $max)) { push(@{$mylist{$2}}, $_); } } } my @keys = sort (keys %mylist); foreach my $key (@keys) { foreach my $thing (@{%mylist}{$key}){ foreach my $it (@$thing) { print "$min\n"; print "$max\n"; print "$it\n"; print "$key\n"; print "$thing\n"; print "@keys\n"; last; } } } #### 27-Jun-2001 12:08:19.17 SendSMReq:T:1069 D:19203311338 O:Voice Mail MWI P:0x20 C:0xe0 V:07-05 12:08 <20> 27-Jun-2001 12:08:19.36 SendSMCnf:AbsSub:1068 27-Jun-2001 12:08:19.56 SubmitInd:T:0 D:19207024720 O:19202928411 P:0x0 C:0x0 V:09-11 12:08 27-Jun-2001 12:08:20.05 SubmitInd:T:0 D:19207137406 O:19203314700 P:0x0 C:0x0 V:06-28 12:08 27-Jun-2001 12:08:20.30 SendSMReq:T:1070 D:16083089587 O:16083089560 P:0x20 C:0x0 V:07-05 11:02 27-Jun-2001 12:08:20.31 SubmitRsp:0 27-Jun-2001 12:08:20.32 SubmitRsp:0 27-Jun-2001 12:08:21.62 SendSMCnf:StatOK:1065 27-Jun-2001 12:08:22.36 SendSMCnf:StatOK:1060 27-Jun-2001 12:08:22.56 SendSMCnf:StatOK:1063