in reply to Log file backup

$logfile=~/(.*)\.tar\.gz$/; my $dirname=substr($1,0,-2);
If the match fails, that $1 will be wrong. Never use $1 unless it's in the conditional of the match test. I'd change those two lines to:
$logfile =~ /(.*)..\.tar.gz$/ or die "Bad non-match on $logfile"; my $dirname = $1;

Also, your "link/unlink" pair can be replaced by a simple "rename". They're equivalent under the hood, with a lot less duplication.

-- Randal L. Schwartz, Perl hacker