in reply to capture STDOUT, STDERR to TWO different perl variables

use Capture::Tiny qw/ capture /;

my ( $stdout, $stderr ) = capture { # your code here };

See also: IO::CaptureOutput.