@sortedbus = sort {$b <=> $a} (@busdir); foreach $bus (@sortedbus) { @splbus = map {split (/_/, $bus, 1)} @sortedbus; if ($today >= @splbus[0]) { for ($i=0; $i++;) { $pers = @buschecked[i]; } # End for loop to populate the sorted, checked array } # End if statement to check the current date against the Begin dates } # End foreach loop to pull each name from the sorted array, check the begin date and populate the final array