#!/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; } } }