#! /usr/bin/perl -w use strict; my %mylist; my $min; my $max; my $range; my $line; #Get the range and enter data in this format with no spaces YYMMDD-YYMMDD $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+$//; chomp(@ARGV = ) unless @ARGV; for (@ARGV) { if ($_=~ m/(\w+)\.(\d+)\.(\d+)\.(\d+)$/) { #push the restricted range of filenames onto a hash of arrays keyed on the #data field if (($3>= $min) && ($3 <= $max)) { #$3 is date field, $4 is time field push(@{$mylist{$3}}, $_); } } } my @keys = sort (keys %mylist); foreach my $key (@keys) { foreach my $thing (@{%mylist}{$key}){ foreach my $it (@thing) { print "$it\n"; } } }