U
Uno
On 2011-03-24 03:22, Uno<[email protected]> wrote:
Your script doesn't contain anything which corresponds to "besides the
directory itself". You want that you have to program it. Perl can't read
your mind.
This recent one might, but again I have trouble seeing the basic control:
$ perl find2.pl
../text1 Tue Mar 22 21:31:45 2011
$ cat find2.pl
#!/usr/bin/perl -w
use strict;
use File::Find;
@ARGV = (".") unless @ARGV;
my ($age, $name);
sub youngest {
return if -d;
$age = (stat(_))[9];
$name = $File::Find::name;
}
find(\&youngest, @ARGV);
print "$name " . scalar(localtime($age)) . "\n";
$ ls -t
find2.pl lst2 find1.pl symirror rmtree1 lst ch09.code
text2 text1 uvi rmtree2 rename fdirs
$
I don't see why execution would want to go through youngest more than
once, to begin with.
Don't google, read the documentation that comes with perl
perldoc -f -M
(Prefixing a term with "-" excludes that term from the search in Google.
You didn't want to search for all pages except those which contain an
"M", did you?)
Do you have a context to see some output for this?
while (<>) {
chomp;
next unless -f $_; # ignore specials
#...
}