What I learned from Mark Jason Dominus:
Code repeated within a single script: Refactor into subroutine.
Code repeated across scripts: Refactor into module.