There's a lot of old code out there, and a lot of it is in Perl. Sometimes its good, some of its bad, and a lot of its ugly. What to do with it? Usually you just throw it away and rewrite, at a high cost and effort. Or it’s left where it is with everyone afraid to touch it for fear of it breaking out of spite.
Refactoring provides an alternative, to actually improve the design of old code in place potentially saving vast tracts of work from the bit bucket. It involves many small, well-defined, systematic changes that do not effect its function and yet make it more readable and flexible. It can work for something as small as detangling a noisy regex to as large as rewiring an entire class hierarchy.
Traditionally, refactoring has been reserved for smaller and more strictly OO languages like Java and Smalltalk. Here we show how it can be applied to Perl along with new refactorings unique to Perl and what existing ones don't work for Perl. We'll also look into the problems of automating refactoring. As the grand finale, we'll tear into a piece of code from the Perl core library.later than July 1 2001.