use strict; use File::Copy; my $PPath=($ENV{Project}); my $LogPath=("$PPath/midnight_reset/log"); my $CPath=($ENV{CONFIG_DIR}); $CPath=~s/\\/\//g; my $file; my $logpath=("$CPath/Agents/log"); opendir (DIR, $logpath) || die "Cannot open dir $logpath: $!"; my @files=grep(/\.log$/i, readdir (DIR)); foreach $file (@files) { unless (copy ("$logpath/$file", "$logpath/$file.old")) { print "Fail to rename $file\n"; } } closedir (DIR);