in reply to STDIN schizofrenia

Thanks to all of you
My purpose was to browse incomming records one at a time, and let the user decide if he wanted to see one more.
I combined several of the ideas suggested here:

Finally the script turned out like this (only skeleton showned):
#!/usr/bin/perl use strict; use warnings; use Term::ReadKey; # Is data comming? usage() unless ( ( ! -t STDIN ) || ((defined($ARGV[0])) && ( -f $ARGV[ +0] )) ); open(TTY,"+</dev/tty") or die "Couldn't open tty: $!\n"; # input record separator is \x1d $/ = "\x1D"; while ( my $rec = <>) { next unless defined $rec; show_formatted_record(); print TTY "\n\nOne more? y/n "; ReadMode('cbreak', *TTY); my $answer = ReadKey(0, *TTY); ReadMode('normal', *TTY); last if $answer !~ /^[yY]$/; } print "\n"; #---- functions: sub usage { print "usage: ...\n"; exit 1; } sub show_formatted_record { print "..."; }
Thanks again,
L