To continue on wazat's post, use substr and eq instead of regexs for such ridiculously simple patterns. It will be faster.
my $file_time = (stat($full_name))[9];
my $diff = $now - $file_time;
$diff = $diff / 86400;
my $read = localtime($file_time);
combine statements 1, 2, and 3. Something like
my $file_time;
my $diff = ($now - ($file_time = (stat($full_name))[9])) / 86400;
my $read = localtime($file_time);
less assignments/reads and less pp_nextstate ops.
$diff = $diff / 86400;
my $read = localtime($file_time);
if ( $diff > 93 ) {
print FILE "$full_name : $diff : $read\n";
unlink "$full_name";
} elsif ( $diff > 3 ) {
next if (/\.gz/);
Optimize out the division by multiplying 93 and 3 by 86400, and comparing to the larger numbers than doing the division. And substr/eq instead of the .gz regex.
unlink "$full_name";
That looks bizzare like someone who has never done Perl before, don't do that.
my $read = localtime($file_time);
Don't do that, don't print the converted time to console, just the unix time. If someone really wants read the log they can do the conversion themselves.
IDK if you can do it with stat() or not, but get the -f and -d and stat on $full_name into exactly ONE syscall, save results to lexicals, then process the results. Don't do redundant I/O calls.
I would guess if you used Nytprof (you should have used that BEFORE coming to perlmonks), your script is either I/O bound to disk/filing system or CPU bound in gzip compression algoritm.