# note vertical bar (pipe) at end of command open PH, "commandline|" or die "commandline: $!"; while () { # ... do something with each line of output } close PH or die "commandline: $!";