Last active
December 28, 2015 22:09
-
-
Save AndrewRussellHayes/7570057 to your computer and use it in GitHub Desktop.
reads and lists a directory forwards and backwards by date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $path = '/home/opuperl'; | |
opendir my($dirh), $path or die "can't opendir $path: $!"; | |
my @flist = sort { -M $a <=> -M $b } # sort by mod time | |
map { "$path/$_" } # need full paths for sort | |
grep ! m/^\./ # remove dotfiles | |
,readdir $dirh; | |
closedir $dirh; | |
use Data::Dumper; | |
print "Newest First\n".Dumper( @flist )."\n\n"; | |
################################################################################ | |
my $path = '/home/opuperl'; | |
opendir my($dirh), $path or die "can't opendir $path: $!"; | |
my @flist = reverse sort { -M $a <=> -M $b } # sort by mod time | |
map { "$path/$_" } # need full paths for sort | |
grep ! m/^\./ # remove dotfiles | |
,readdir $dirh; | |
closedir $dirh; | |
use Data::Dumper; | |
print "Oldest First\n".Dumper( @flist ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment