in reply to Re^2: Replace multiple strings in a string
in thread Replace multiple strings in a string
++. I absolutely agree. I mentioned speed only as side effect and heavily qualified the claim that it is faster ("probably somewhat faster"). I agree that speed is probably not really relevant, let's say that it is good enough to know at least that it is not slower. Clarity is the most important reason, and although TIMTOWTDI, I am almost always using the Perl-style for loop for that reason (and also avoiding to use the $i array index when possible).
Update: I just saw your other post below suggesting the use of a hash or an array of arrays (or array of hashes or similar data structures) and thus getting rid of the need to use array subscripts, I was actually also thinking of something similar, and I agree that this is a much better solution. The idea of walking through two arrays in parallel relying on a common index is at best clumsy, in view of the efficient data structures (in terms of coding simplicity) offered by Perl.
|
|---|