|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Best Practice for replace subby Skeeve (Vicar) |
| on Mar 01, 2013 at 09:59 UTC ( #1021213=perlquestion: print w/ replies, xml ) | Need Help?? |
|
Skeeve has asked for the
wisdom of the Perl Monks concerning the following question:
Hi I often find myself writing code like this:
Note: Please don't tell me about moduls being able to do exactly this encoding/replacements as this is just an example for several tasks where I need to replace substrings with other strings. My bad feeling about this is: I'm using kind of global variables which I initialize once because I simply don't want to assign the hash (%ENCODE) and the accompanying scalar ($ENCODE) each time the encode($string) is invoked. So they need to be on global level. But it does not "feel right". What's your proposal against this? Or what's your view on this? s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{% +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||