Hi, If you wish to select all files that are directly under given directory you can implement the following (in pure perl fashion):
sub numerically { $b <=> $a;} $DIR = <Set in you directory>; $THRESHOLD_IN_DAYS = 3; my %time_to_file; my $currTime = time(); #Store all file in hash with time as key. for each my $file ( grep (-f,<*>)) { my $time = stat($file)->mtime; $time_to_file{$currTime - $time} = [] unless ( exists $time_to_file{$currTime - $time}); push @{$time_to_file{$currTime - $time}},$file; } #Sort by time from the new to the old my @sorted = sort numerically keys(%time_to_job); my $time_threshold_in_seconds = $THRESHOLD_IN_DAYS * 24 *3600 foreach my $atime (@sorted) { if ($atime >= $time_threshold_in_seconds) { foreach my $afile ($time_to_file{$atime}) { print "$afile is older than $THRESHOLD_IN_DAYS lets delete it\n"; unlink($afile) or warn "Cannot delete $afile. $!"; } } } Hope that helps Yaron Kahanovitch ----- Original Message ----- From: "Craig Schneider" <[EMAIL PROTECTED]> To: beginners@perl.org Sent: Tuesday, April 10, 2007 2:19:40 PM (GMT+0200) Auto-Detected Subject: Sorting dir output Hi Guys How could I exec a 'dir' command on a dos system and put the output in an array, sort by date and the files that are older than 3 days be moved into a folder called 'history' Thanks Craig -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/