|
|
| "be consistent" | |
| PerlMonks |
Re^3: Putting the stringified Regexp object into codeby roboticus (Canon) |
| on Nov 06, 2012 at 20:44 UTC ( #1002576=note: print w/ replies, xml ) | Need Help?? |
|
The reason kennethk is wondering why you're avoiding closures is that much template-generated code can be easily replaced with a closure. Generally a string eval can be replaced with something better. Munging strings to generate functions is certainly possible, and many have done it. But sometimes it's just easier to generate the function itself. An example (very loosely) based on your sample code:
Update: Added the third validator function example, just for variety. Also added a couple of comments. Update: Re-read thread and properly attributed suggestion. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||