in reply to Recording input and output of a command in file
I would advise you to use Log4Perl and to split the code from the logging - thus you can keep your code and change your logging wo changing code.
Disadvantage is that your client's perl distributions might not necessarily have Log4Perl installed.