open IN, "cmd args |" or die $!; while( ) { # do something with each line of input } close IN;