Not especially elegant - I only strive for grace, not necessarily achieve it :) - but here's something that I think is a bit cleaner and more direct:
#!/usr/bin/perl use common::sense; use File::Find; my $dir = "/some/dir/some/where"; my %dirs; finddepth(\&newest, $dir); sub newest { return unless -f; my ($d, $n) = ($File::Find::dir, $File::Find::name); $dirs{$d} ||= $n and return; $dirs{$d} = $n if (stat($n))[9] > (stat($dirs{$d}))[9]; } print "$_: $dirs{$_}\n" for keys %dirs;
-- I hate storms, but calms undermine my spirits. -- Bernard Moitessier, "The Long Way"
In reply to Re: File::find hack
by oko1
in thread File::find hack
by nemesdani
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |