Hi, On Apr 10, 2007, at 3:27 PM, John W. Krahn wrote:
Craig Schneider wrote:Hi GuysHello,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 movedinto a folder called 'history'# open the current directory opendir my $dh, '.' or die "Cannot open '.' $!"; # get files older than three days my @files = grep -M > 3, readdir $dh; closedir $dh; for my $file ( @files ) { rename $file, "history/$file" or die "Cannot move '$file' $!"; }
You can also use File::Find::Rule for that: <code> use strict; use warnings; use File::Copy; use File::Find::Rule; use File::Spec; my $basedir = "/Users/igorsutton/workspace"; sub move_file { move( $_[2], File::Spec->catdir( $basedir, 'history', $_ ) ) or warn $!; } my $rule = File::Find::Rule->new; $rule->directory()->name('trunk')->exec( \&move_file )->in($basedir); </code> -- Igor Sutton [EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part