#!/usr/bin/perl -w my %mylist; my $datemin; my $datemax; my $timemin; my $timemax; my $range; my $rangex; # get the range (in this throwtogether it must be entered # with no spaces in the form YYMMDD-YYMMDD) # Get the range $range = ; $rangex = ; # Break up the range ($datemin, $datemax) = split /-/, $range; ($timemin, $timemax) = split /-/, $rangex; # Squeeze out leading and trailing spaces $datemin =~ s/^\s+//; $datemin =~ s/\s+$//; $timemin =~ s/^\s+//; $timemin =~ s/\s+$//; $datemax =~ s/^\s+//; $datemax =~ s/\s+$//; $timemax =~ s/^\s+//; $timemax =~ s/\s+$//; # Get the filenames and break into fields chomp(@ARGV = ) unless @ARGV; for (@ARGV) { if ($_ =~ m/(\w+)\.(\d{4})(\d{6})(\d{6})$/) { # push the restricted range of filenames onto a hash of arrays # keyed on the date field if (($3>= $datemin) && ($3 <= $datemax) && ($4>= $timemin) && ($4 <= $timemax)) { push(@{$mylist{$3}}, $_); } } } my @keys = sort (keys %mylist); foreach my $key (@keys) { foreach my $thing (@{%mylist}{$key}){ foreach my $it (@$thing) { print "$it\n"; } } }