#!/usr/bin/perl -w $| = 1; # make line buffered print "Write something: \n"; while (<>) { print; if ($_ =~ /aaa/){ exit; } }