foreach $log (@logfiles) { rename($log,$log.".tmp"); ProcessLogfile($log.".tmp"); } foreach $log (@logfiles) { del($log.".tmp"); };