in reply to problems redirecting STDOUT and STDERR to a $variable

I think your "uninitialized value" warning is explained in Use of uninitialized value in open second time but not first. The fix is to initialize $out when it's created.

my $out = '';

(I tried this, and it worked for me.)