in reply to Re^4: Get newest folders inside directory
in thread Get newest folders inside directory

Read the comments in number order:

## which are finally assigned to the array ## 4 # +# my @newest = ( ## This runs next, and sorts the directories ## 2 +## ## from most recent to least recent sort{ -M $a <=> -M $b } ## this runs first, generates a list of files/dirs in root ## 1 +## ## which it then reduces to just a list of directories grep -d, glob '/*' )[0..19]; ## then this "list slice" selects the 20 most recent ## 3 # +#

It is equivalent to:

my @allFilesnDirs = glob '/*'; my @allDirs = grep -d, @allFilesnDirs; my @allDirsSortByDateTime = sort{ -M $a <=> -M $b } @allDirs; my @newest20 = @allDirsSortedByDateTime[ 0..19 ];

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy