in reply to Get newest folders inside directory

@newest = (sort{ -M $a <=> -M $b } grep -d, glob '*' )[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

Replies are listed 'Best First'.
Re^2: Get newest folders inside directory
by Anonymous Monk on Nov 09, 2010 at 23:35 UTC
    Thanks for your reply. Where would I specify the root folder I want to check?

      In the quotes before the '*'. If you're on win, you might want to include a drive specifier in there also: glob 'c:/*'

      @newest = (sort{ -M $a <=> -M $b } grep -d, glob '/*' )[0..19];;

      Also look at -A & -C as applicable on your OS.

        Hi,
        This works great.
        Can anybody explain how this works internally? i mean which executes first and which next, left to right etc. what is the input to sort? I am new to Perl.

        Thanks
        Thanks a lot, that works great! :-)