>>>>> "CH" == Chap Harrison <c...@pobox.com> writes:
CH> On Apr 25, 2011, at 3:12 AM, Uri Guttman wrote: >> finally, i am very proud of the code quality in those two modules. feel >> free to look at them, ask me questions, flame the code, etc. i have no >> issues with anything said about my code. CH> I'm an "advanced beginner" and I'm embarrassed to say that, CH> although I've read the Synopsis and Description in the module CH> documentation, and searched perldoc, I can't figure out what a CH> 'template' is or what its purpose is, in the context of Perl. the classic example of a template is a form letter. the body is the same but you have a list of addresses, names, etc that you fill into spots to generate each unique letter. many web pages and other documents are built with templating. php is ALL templating but it embeds code inside the templates (as some templating modules do). CH> Also, the synopsis for Template::Simple included the following: CH> # this is data that will be used to render that template the keys CH> # are mapped to the chunk names (START & END markups) in the CH> # template the row is an array reference so multiple rows will be CH> # rendered usually the data tree is generated by code instead of CH> # being pure data. CH> Is this properly punctuated? I can't parse this CH> sentence/paragraph. yes, it is missing a period or more. read the extras/cookbook.pl for many runnable examples which should help. CH> I'm not saying that an introduction to templates belongs in the CH> module documentation, but can you (or somebody else) tell me what, CH> generically, a "Template" module is for? web pages are the most popular use but templates can be used anytime you need text with variations. in perl sprintf is effectively a template and even a double quoted string with interpolated variables can be called a template. the problem with a string is that you can't read the template from an outside source as it is code and that required the evil string eval (which i shot down when posted for a solution to that very problem). another real world template is the boilerplate in contracts and legal documents. they have the document written out and fill in all the blank parts. it is a very common concept and well worth knowing how to do it in perl. i ran into needing them many years ago and slowly developed my own module as it was simpler than anything i saw. it evolved from a single line with an s/// call and a hash of keys/values to a 37 line sub that did most of what i needed. later i created a proper module with OO, tests, docs, etc. which is what i have and use now. uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/