I could copy the sub into a new sub that implements basically the same functionality but with this small change.
Don't. In the long run, and in the large scale, this will create a maintenance nightmare. For example, if you later realize that there's a bug in one of the copy-n-pasted common code fragments, or when you need to make some modification, you'll have to apply the fix/change in every place that same code appears... Not only is this tedious, but experience has shown it is often not done properly, introducing new hard to track bugs.
See also the (more generally scoped) anti pattern Cut-And-Paste Programming.
In reply to Re: Best way to handle small changes to subroutines
by almut
in thread Best way to handle small changes to subroutines
by code4pay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |