CGI File copy
File copy
#!/usr/bin/perl
use strict;
use File::Copy;
my $age;
my $destination="/home/chris/tmp/";
my $sourcedir="/home/chris/bin/";
my @files=`cd $sourcedir && ls`;
# iterate and copy each one
foreach (@files){
chomp;
# get the age in seconds
$age = (time() - (stat($sourcedir.$_))[9]);
print "\n$sourcedir.$_ is is $age seconds old\n";
if($age<300){
copy("$sourcedir$_","$destination$_");
}
}