in reply to Capturing output of commands to a file
You might want to take a look at Capture::Tiny. It's tee function can be used to run a system command where it's "output is captured as well as passed on to the original STDOUT and STDERR".