Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I need to get this script to also list and search subdirectories. please advise what I am doing wrong?
use strict; my $finder = $File::Find::name; #not sure what to do here. my $newfile = "/perl/bin/"; opendir(DIR,$newfile); my @files = readdir(DIR); close(DIR); chdir ($newfile) or die "Could not change to $newfile directory\n$!\n"; for(@files) { my $filename = $_; next if ($_ != m/^\.+$/); my $modtime = localtime ( (stat($filename))[9] ); print "File = $filename\n"; print "Mod date = $modtime\n"; }

Replies are listed 'Best First'.
Re: Finding mod times in subdirectories.
by the_slycer (Chaplain) on Aug 15, 2002 at 14:54 UTC
    Reading the documentation for File::Find will show you what you need to do.

    Something like
    use File::Find; my @directories = ('/usr/local'); find(\&wanted, @directories);
    Where you have a sub called wanted in your script to do what you want to do to the file.