greenhorn has asked for the wisdom of the Perl Monks concerning the following question:
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.
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:
for ( @array ) { s/\s+/\t/; s/elementary/my dear Watson/g; }
But if the routine is re-written as follows: do {s/\s+/\t/; s/elementary/my dear Watson/g;} for @array;
. . . the cursor "lands" there only once. The entire array appears 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?