use strict; use warnings; my @array = qw(file1 file2 file3 file4 file5 file6 file7 file8 file9); #array with file names my @reversed_array = reverse @array; #reverse @array so reading from the last element my @files; #this array will contain 8 file names once done for(0 .. 7 ){ #8 iterations push @files, $reversed_array[$_]; } #print "$_\n" for reverse @files; print "$_\n" for @files;