I think you can use before() to accomplish this.
From the docs:
$object->before()
before() returns the 'before' part of the last
expect() call. If the last expect() call didn't match
anything, exp_before() will return the entire output
of the object accumulated before the expect() call
finished.
And further down in Q&A:
Ok, so now how do I get what was read on the handle?
$read = $process->before();
jeffa
L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)
|