#!/usr/bin/perl -w open (PIPE,"printsth |") or die $!; while() {print; last if $i++ >=1000; } close(PIPE) or die "Quit with exit status: $? message: $!" ;