Monks,
I have a subroutine in a module that takes a data structure and runs the exact same page of code on two inputs from that structure. What's the recommended way to reuse that code?
The code already has a bunch of loops and ifs so I'm hesitant to just wrap it in a another loop as it will disappear off the right of my screen. I don't really want a global sub that will only get called exactly twice. I think I want a lexical sub but they are experimental and others might want to run my code on perl <5.18. Is an anonymous sub the right thing here? Copy and paste just seems wrong.
What's the best way to reuse my chunk of code?
EDIT: Changed the title to something more descriptive.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |