Skip to content

Instantly share code, notes, and snippets.

@choroba
Created September 2, 2016 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choroba/d70a31d65d66f9a64f411db21c8931c9 to your computer and use it in GitHub Desktop.
Save choroba/d70a31d65d66f9a64f411db21c8931c9 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
use Time::Piece;
open my $GIT, '-|', qw{ git log --name-status --reverse };
my $date;
my %last_touched;
while (<$GIT>) {
if (my ($date_string) = /^Date:\s+(.*)/) {
$date = 'Time::Piece'
->strptime($date_string, '%a %b %d %H:%M:%S %Y %z')->epoch;
} elsif (my ($file) = /^[ACDMRTUXB]\s+(.*)/) {
$last_touched{$file} = $date
if $file =~ /\.(?:p[lm]|pwt|t)$/ && -f $file;
}
}
for my $file (
sort { $last_touched{$b} <=> $last_touched{$a} } keys %last_touched
) {
say $file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment