Sigh.
Yes, templating is a nice solution to a number of problems, and can really clarify your code. But keep in mind it is
not always bad. Sometimes a quick-and-dirty solution is easier. Many people like Perl because it enables you to do things that would otherwise take hours to do.
- Object orientation is always better
In many cases, OO is just a pain in the ass, and a functional interface is better. I really like perl 6's ability to create your own operators.
- Embedding text in scripts is always wrong
A quick-and-dirty solution can save both time and money. Besides, there's nothing wrong with embedding just a little. In situations where overloaded servers have to be used, templating can be too slow.
- Prototypes should never be used
Tilly told me why prototypes are bad. And they sure are. But sometimes, they're good. The (&@) for creating map-like syntax, or the () prototype to let perl inline your sub (great for constants).
- Calling external programs when perl can do it is about as wrong as it can get
There's the quick-and-dirty approach again. Although wrong in many production projects, it can speed up development a lot if you're creating a one-time hack, or a simple sysadmin script.
- XML is the #1 way to store data
XML is a hype. XML is a nice format to store data in, but there's a lot of ways to do it. I personally dislike pipeline seperated files, but even those can be quite good.
- Never use a regex to grab the filename out of a path
($foo = $bar) =~ s!.*/!! is easier than using File::BaseName. The code's not portable, but not all code has to be.
- Death to Dot Star!
Dot star has a function. If you know what it does, and it does what you want, USE IT.
- Etcetera etcetera
Many things, including templating are overrated. Some developers (including yours truly) forget there are other solutions that can be as good, or maybe even better in particular cases.
Maybe you're right about this script. Maybe _this_script_ should use a templating solution. Add "in most cases", "in this case" or something like that and you're right.
Keep in mind: TIMTOWTDI, and some ways TDI are better than others, but that doesn't mean the worse ways should be avoided completely.
2;0 juerd@ouranos:~$ perl -e'undef christmas'
Segmentation fault
2;139 juerd@ouranos:~$
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.