![]() |
|
Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
(Ovid) Re: Orcish Maneuverby Ovid (Cardinal) |
on Dec 06, 2001 at 23:16 UTC ( [id://130032]=note: print w/replies, xml ) | Need Help?? |
The Orcish Maneuver is a term coined by Joseph Hall in his book "Effective Perl Programming" (co-authored by merlyn). Here's the essence of it:
The "orcish" (a bad attempt at humor: "or cache") maneuver basically caches the results of an expensive lookup using the ||= operator. This operator says, in the above code, that $times{$a} will be evaluated or, if it is false, set it to the value of -M $a. (-M is the file test operator for last modified time). This allows you to cache the results of -M rather than call it every time. This has the same effect as:
Cheers, Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
In Section
Seekers of Perl Wisdom
|
|