in reply to Re: system "gzip $full_name" is taking more time
in thread system "gzip $full_name" is taking more time
combine statements 1, 2, and 3. Something likemy $file_time = (stat($full_name))[9]; my $diff = $now - $file_time; $diff = $diff / 86400; my $read = localtime($file_time);
less assignments/reads and less pp_nextstate ops.my $file_time; my $diff = ($now - ($file_time = (stat($full_name))[9])) / 86400; my $read = localtime($file_time);
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.$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/);
That looks bizzare like someone who has never done Perl before, don't do that.unlink "$full_name";
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.my $read = localtime($file_time);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: system "gzip $full_name" is taking more time
by parv (Parson) on Dec 09, 2013 at 08:20 UTC |