#!/usr/bin/perl -w use strict; $| = 1; my $stream; while (<>) { $stream .= $_; } open STDIN, "/dev/tty" or die; print "Do you want to process the stream? "; my $ans = ; chomp $ans; print "Got '$ans'\n"; print "stream = $stream"; #... exit; __END__ $ echo foo | ./stdin Do you want to process the stream? yes Got 'yes' stream = foo $