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$/; my $dirname=substr($1,0,-2);
$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
In reply to •Re: Log file backup
by merlyn
in thread Log file backup
by munk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |