On Tue, 25 May 2010, Uri Guttman wrote:
so that is 6 ways to do it without eval and tied. :)
Thanks, I did in fact consider, and in a couple cases implement, all of
those possible solutions, but was not happy with any of them.
Basically, either the template is too cluttered:
<a href="[%url%]">[%title%]</a>...
or I am using regexp replacement. I suppose I trust perl's parser and
variable interpolation more than my own, which is why I like eval.
I won't know the names of the methods until run-time since I am building a
general purpose utility that can be used with any object.
If we don't like eval I might be able to use String::Interpolate instead,
though honestly I have read their documentation 3 times now and still
don't precisely understand it.
Broadly, what I want to do is almost what is described here:
http://dev.perl.org/perl6/rfc/222.html
except that I have one object on which all the methods will be called, so
no need to repeat the object many times.
Possibly that means I can "use v6" and get what I want, although I have
not read up on what else that would change backwards-incompatibly.
So it sounds like the best practice would be to go back to my own regexp
substitution. Hm. Is there perhaps a packaged regexp somewhere that finds
and replaces exactly the same strings of the form $abcd that the perl
parser would?
- Alex Aminoff
BaseSpace.net
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm