perlquestion
greenhorn
<p>I use an IDE for perl (Perl Builder). As with other such programs: the statement that's about to be executed is highlighted just before you execute it. Then the highlight-bar "lands" on the next statement.
<P>In a case like the one just below, the highlight-bar "lands" on the substitutions as many times as there are elements in the array:</p>
<code>for ( @array ) {
s/\s+/\t/;
s/elementary/my dear Watson/g;
}</code>
<p>But if the routine is re-written as follows:
<code>do {s/\s+/\t/; s/elementary/my dear Watson/g;} for @array;
</code>
<p>. . . the cursor "lands" there only once. The entire array <i>appears</i> to be processed in a single step. I've assumed that this difference is simply an artifact of the way the IDE displays what it's doing. But considering how quickly the one-liner seems to execute in the IDE--even when the array is rather large--it got me wondering: does making such routines as terse as possible actually improve execution speed?</P>