Craig Schneider wrote:
> Hi Guys

Hello,

> 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'


# 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' $!";
    }




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to