more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Why don't you try to do this more "all at once"?
First, note that tr/// is the right tool for single character substitution lists -- it's heavily optimized for this kind of thing. Second, it seems to me that your $count variable may be redundant. Why not make one hash with keys the "old" values and the values the "new" values -- that sounds odd, but basically: ...but do this where you are building %array1 and %array2 so you don't need to use $count or the array hashes at all. Aside: in perl's common parlance, "array" typically refers to an integer indexed object like you are using your hashes above, but the hash construct is much more flexible (and more expensive to use in terms of resources). Anyway, with a %replacements hash you can then do: This does all your replacements with one evaluation. Again, note that this is really only appropriate when you need to replace more than single characters.
In reply to Re: Substitution problem.
by snax
|
|