A few years ago at work, I had to optimise the running time of a CGI script that is part of a bigger reporting system. The program architecture is a bit strange; in this case, the problem was accessing inherited package variables (yes, this is a thing). The class hierarchy is only three levels deep, but the variables in the leaf class get millions of accesses in a script run and many of them come from the parent or grandparent class. The variables were accessed using inherited methods.
Instead of redesigning the architecture (which is still on the todo list), I wrote a subroutine that takes a list of variable names as input (like '%FOO', '$BAR'), traverses @ISA breadth first and inspects the symbol table of each package it encounters. If it finds a typeglob with the right name and a slot of the right type, the sub imports that slot into the calling package. Of course, the subroutine checks the symbol table of the calling package for %FOO and $BAR before the expensive lookup.
I guess it's more about working around a suboptimal software architecture, but you couldn't solve it like this in certain other programming languages.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link
or How to display code and escape characters
are good places to start.