File::Find::Age - mtime sorted files to easily find newest or oldest
my $oldest = shift(File::Find::Age->in('lib/', 't/'))->{file}; my $newest = pop(File::Find::Age->in('lib/', 't/'))->{file}; my $oldest_mtime = shift(File::Find::Age->in('lib/', 't/'))->{mtime}; my $newest_mtime = pop(File::Find::Age->in('lib/', 't/'))->{mtime};
Returns array ref with list of files found in @folders sorted by mtime.
@folders
Sorted list includes one hash ref per file. Ex.:
$VAR1 = [ { 'mtime' => 1239916327, 'file' => 't/00_compile.t' }, { 'mtime' => 1239916327, 'file' => 't/pod-coverage.t' }, { 'mtime' => 1239916327, 'file' => 't/distribution.t' }, { 'mtime' => 1239916327, 'file' => 't/pod.t' }, { 'mtime' => 1284468458, 'file' => 't/pod-spell.t' }, { 'mtime' => 1341080967, 'file' => 'lib/File/Find/Age.pm' } ];
I'm using it to find newest mtime of static web files and use this number to invalidate browser cached versions of this files.
<link href="/static/css/site.css?t=1341080054" rel="stylesheet"> <script src="/static/js/site.js?t=1341080054"></script>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
File::Find::Rule
Jozef Kutej
To install File::Find::Age, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Find::Age
CPAN shell
perl -MCPAN -e shell install File::Find::Age
For more information on module installation, please visit the detailed CPAN module installation guide.