@tmp1 = readdir LOGS; # @tmp now contains the files listed in "." @tmp2 = grep {/.*\.log/} @tmp1; #@ tmp2 now contains files that contain ".log" @tmp3 = map {-M $_} @tmp2; #@tmp3 now contains what? @val = sort @tmp3;