in reply to How to capture data from STDOUT?

I may be misunderstanding the problem, but from your question I have the impression that this is not something you need to solve using Perl. (??)

Executing:

binprogram >somefile
at the shell should do it.

"Livet är hårt" sa bonden.
"Grymt" sa grisen...