#!/usr/bin/perl use strict; use warnings; open(F, '-|', "cat file | /usr/bin/mycommand") or die "Something nasty happened with my command"; while () { # do something with each line of your output } close F;