PERL - Selecting specific files based on 'date stamp' values

Hi,

I've list of files in a directory, which have date stamp value in their names.

ex: 
abc_data_20071102.csv, 
abc_data_20091221.csv, 
abc_data_20100110.csv, 
abc_data_20100222.csv, 
abc_data_20080620.csv,... etc., 

I need to select and process only files, within the given date range.

ex: files starting from the date 20090101 to 20101231

I've written below scrtipt to select files starting from 'abc_data_' and ending with '.csv'.
This script is selecting all files starting abc_data_ and ending with '.csv'.

my @files = </test/ganap/abc_*.csv>;
foreach my $inputfilename (@files) {
   open( my $in_fh, "<", $inputfilename ) or die "Can't open $inputfilename : $!";
#.......................... file processing
}
close($in_fh);

Could any of you help me to achieve my selection criteria?:confused:

my @files = < /test/ganap/abc_20[01][09][0112].csv >;
foreach my $inputfilename (@files) {
   open( my $in_fh, "<", $inputfilename ) or die "Can't open $inputfilename : $!";
#.......................... file processing
}
close($in_fh);

;);):wink:

Thanks for your quick reply ahmad diab. :slight_smile:

But, files selecting start and end dates are commandline parameters to the programme.

my $startdate  = $ARGV[0];
my $enddate  = $ARGV[1];

my @files = </test/ganap/abc_*.csv>; #current approach, which is wrong.
foreach my $inputfilename (@files) {
   open( my $in_fh, "<", $inputfilename ) or die "Can't open $inputfilename : $!";
#.......................... file processing
}
close($in_fh);

So, I need help to modify my script :confused:

well that's the beauty of ASCII and the ISO date format
you can just do an aplhabetic comparison,
if (abc_data_20090312 gt abc_data_20080312)

Thanks for your approach 'bigearsbilly'.

But are there any otherway, than the aphanumeric comparision for the date field? I'm very curious to know more?