in reply to capturing the output of eval()

Two options.

You can fork, eval in the child, and capture the output in the parent.

You can use open to dup the original STDOUT and STDERR somewhere else, tie STDOUT and STDERR (eg with IO::Scalar), eval, untie and replace with the originals.

  • Comment on Re (tilly) 1: capturing the output of eval()