in reply to Re: Re: How does find() build its tree.
in thread How does find() build its tree.
For example, the following script will perform a find on /tmp, then print all of the file names in order from most recent to oldest:
As you can see, within the wanted function, we collect each filename and the time it was last modified. Once find() finishes, we then sort the files into the desired order and print them out.#!/usr/bin/perl -w use strict; use File::Find; my @files; sub wanted { push @files, [ $File::Find::name, -M $_ ]; } find(\&wanted, "/tmp"); foreach (sort {$a->[1] <=> $b->[1]} @files) { print $_->[0], "\n"; }
|
|---|