opendir(DIR, $dir) or die $!; my $c_array_1=-3; while (my $file = readdir(DIR)) { $c_array_1++; # Just files next unless (-f "$dir/$file"); # Find files ending in .xml next unless ($file =~ m/\.xml$/); # Change to the date format 123_20070227_REFNUM.xml $file=~/^(\d{3})_(\d{4})(\d{2})(\d{2})_(.*?)/; $year_from= $2; $month_from= $3; $day_from = $4; $temp_date = month_from."/".$day_from."/".$year_from; sort $temp_date; # Sort date here and display:::: print ""; } closedir(DIR); print " ";