in reply to Help with ReadDir and Stat?
You will of course have to add the logic for checking the tile modification time. A shortcut for that is:#!/usr/bin/perl use strict; use warnings; open my $LOG, '>', "$0.log"; my $startdir = $ARGV[0] || '.'; push my @dirs, $startdir; while (my $dir = pop @dirs) { opendir DIR, $dir; my @files = grep !/^\.\.?$/, readdir DIR; closedir DIR; foreach my $file (@files) { my $fullname = "$dir/$file"; $fullname = $file if ( $dir eq "/" ); if ( -d $fullname ) { push @dirs, $fullname; next; } if ( -f $fullname ) { if ( $file =~ /\.dat$/i ) { print $LOG $fullname . "\n"; } } } } close $LOG;
Unless, of course you need the other values that stat returns.my $mtime = stat($file)[9];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with ReadDir and Stat?
by batcater98 (Acolyte) on Mar 13, 2008 at 17:23 UTC | |
by Akoya (Scribe) on Mar 13, 2008 at 17:36 UTC | |
by batcater98 (Acolyte) on Mar 13, 2008 at 18:50 UTC | |
by Akoya (Scribe) on Mar 13, 2008 at 18:59 UTC |