Hello brothers and sisters,
I have recently started a new job developing perl with some definite perl advocates but they tend to be older guys and prefer things like a three line if construct than a trailing if.
That being said, I'm certainly no perl expert, but I have discovered a technique that I enjoy. The technique revolves around situations when a number of tests need to be conducted.
My technique is to place tests into either a hash or array and then eval them via map.
The criticism I get is that eval causes a performance hit that may not be worth it. I have been called out on a couple of issues that later proved to be correct on my part so I tend to verify everything now.
If I have a series of 15 tests I have to perform, I would much prefer to put the 15 tests in a hash, iterate over the keys and do that instead of writing 45 lines of ......
if {
test condition
}
I also just find this way to be plain easier to add new tests if need be.
Should I really be concerned about performance hits? Does eval REALLY cause that much of a performance issue?
Respectfully,
Sherab
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.