$ perl -MJSON -le '$output=`./asdf`; print encode_json([$output])' output to stderr ["output to stdout\n"] $ perl -MJSON -le '$output=`./asdf 2>&1`; print encode_json([$output])' ["output to stdout\noutput to stderr\n"]