in reply to How do I get better at thinking about optimizing my Perl?

A Perl program that doesn't interact with outside entities (database, filesystem, networked thingy, etc) is very rare. In every case I've ever seen one, they have never taken more than a second or two to run. Thus, they didn't need optimizing.

Nearly every Perl program that interacts with an outside entity is almost always bound by the usage of outside entity. For example, optimizing your database tables and the SQL you use will almost always yield enough performance benefit to satisfy. This leads us to the understanding that the primary things that need optimizing are the ways we interact with the outside world. Thus, a while-loop to iterate over a file is (almost) always better than the equivalent foreach-loop.

The one real exception to this are regexes. But, in 12 years, I haven't found a use for the kind of regex that needs optimization. I don't use backtracking, lookaheads (except rarely), and all that other black magic.

As for webapps, fcgi and mod_perl are all you need.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: How do I get better at thinking about optimizing my Perl?