#!/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 HH:MM:SS.TS-HH:MM:SS.TS) # 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+$//; # Open the datafile and break into fields open(FILE, "mon402.log"); while () { if (s/<(.*?)>/TEXT/) { if ($_ =~ m/(\d+\-\w+\-\d+)\s(\d{2}\:\d{2}\:\d{2}\.\d{2})\s+(\w*)/) { # Push the restricted range of filenames onto a hash of arrays # keyed on the time field if (($2 ge $min) && ($2 le $max)) { push(@{$mylist{$2}}, $_); } } } } my @keys = sort (keys %mylist); foreach my $key (@keys) { foreach my $thing (@{%mylist}{$key}){ foreach my $it (@$thing) { print "$it\n"; last; } } }