use Capture::Tiny 'capture'; my ($out, $err) = capture { print "ya"; Text::BibTeX ... system ... }; print "captured out((($out))) err((($err)))";