#!/usr/bin/perl while (<>) { die "Pipe process is now dead\n" if ( /kill/ ); print "Pipe process got $_"; exit(0) if ( $. == 5 ); }