in reply to capture STDOUT, STDERR to TWO different perl variables
use Capture::Tiny qw/ capture /;
my ( $stdout, $stderr ) = capture { # your code here }; [download]
See also: IO::CaptureOutput.