in reply to Redirecting STDOUT to a variable
open (STDOUTHANDLE, "somecommand|"); while ($line = <STDOUTHANDLE>) { # . . . } [download]
note the pipe character at the end of the command.