Have a look at Capture::Tiny.
In reply to Re: How to capture (intercept) output (warnings) of a module by swl in thread How to capture (intercept) output (warnings) of a module by davidfilmer