I'd probably follow the route of Ack, write the code in a separate module and then create a one-script version if that makes distribution easier. See also the Github repository of Ack.
See also FatPacker
I tried to separate the functions of bot of main program but the program doesn't work as intended. I think I will let the program in one .pl file until otherwise.