in reply to executing commands and getting output

Assume your command will return code on STDOUT or STDERR.

Then you could simply do:
my $result = `program`; # for collecting data from STDOUT
and
my $result = `program 2>&1`; # for collecting data from STDERR.
There is no need to redirect the file handle. In the second case, the 2>&1 directive tells the shell to redirect all the output of program's STDERR (file handle 2) to STDOUT (file handle 1), so your perl program can collect the output of it.