in reply to Changing foreach loop for a while loop

Whether you use a 'for' or a 'while' loop, loop overhead takes microseconds per iteration. Yes, 'while' loops can be faster when reading in files, because they read in one line at a time, rather than reading in the whole file before processing the lines.

But that doesn't apply here, you start off with an array already in memory.

Consider that an sql query takes milli-seconds, if not seconds or minutes --- far longer than loop overhead.

Since you're looking at improving performance, the first step is to profile .... type perldoc Devel::DProf into a terminal window or search CPAN.org.

--
TTTATCGGTCGTTATATAGATGTTTGCA

  • Comment on Re: Changing foreach loop for a while loop