I don't see anything that would make that big of a difference. I think the problem is elsewhere.
time is a system call. You could save a little speed by calling it once outside the loop.
If /approv/i should actually checking for equality, lc($_) eq 'approv' is 122% faster when the check is true and 28% faster when the check is false.
Comments not related to performance:
$localtime = FormatTime($moduleField[2]) if $moduleField[2]; $localtime = "n/a" unless $moduleField[2];
could be written
$localtime = $moduleField[2] ? FormatTime($moduleField[2]) : "n/a";
Assigning to $_ is dangerous. And it's not even necessary here. Change
$_ = $headers[$dataCount]; if( /approv/i )
to
if( $headers[$dataCount] =~ /approv/i )
In reply to Re: Foreach Loop Optimization
by ikegami
in thread Foreach Loop Optimization
by upallnight
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |