$output=`tar -tf`; #collects all the output from the "tar -tf" command open TAR, "tar -tf|"; #open a process with a pipe on the right side while(){ #get the output line by line into $_; do_something($_); #process the results; } close TAR;