laziness, impatience, and hubris | |
PerlMonks |
Re: Here documents in blocks [s///r chaining]by kcott (Archbishop) |
on Dec 20, 2020 at 17:00 UTC ( [id://11125503]=note: print w/replies, xml ) | Need Help?? |
Me again. I don't think I've ever written this many responses to a single OP. :-) Use of s///r has been mentioned in more than one post. I wondered if you knew that you could chain them. You can also chain y///r and mix them up. This type of extended construct is valid; although, I can't think of an immediate use for such a beast:
I saw where you'd written that you don't really have time to learn a completely new system. The following may be useful in its own right; however, it may get you halfway to writing a more formal template. When you do get around to looking at templating systems — and I do recommend you at least put that on your TODO list — you'll probably notice the similarities between placeholders like __TOKEN__ here and those used by templating systems, such as <% TOKEN %>. In the following code, the main processing, including the s///r chaining, is all at the front; the (messy) heredocs are written as theredocs and moved out of the way to the end of the code.
When run, that outputs:
— Ken
In Section
Seekers of Perl Wisdom
|
|