« Home | 10. Regular expressions are your friends Per... » | 10 things every Perl hacker know » 

Sunday, May 28, 2006 

Don't reinvent the wheel

9. Don't reinvent the wheel


You should use subroutines, modules, and libraries often. The point is to help you write code faster and keep that code from becoming unmanageable if you need the same functionality in multiple programs, or more than once in the same program. This is accomplished by separating blocks of code from the rest of your source code using subroutines, modules, and libraries. You're better off using a design for the wheel that already exists, rather than reinventing the wheel from scratch, most of the time. In addition, when you're reusing code from a subroutine, module, or library, and you need to improve that code somehow, you only need to change it in one place.


--------------------------------------------------------------------------------

The term "subroutine" in Perl means roughly the same thing as "function" in C.