# # # ReadKey MODE [, Filehandle] # # Takes an integer argument, which can currently be one of the following values: # # 0 Perform a normal read using getc # -1 Perform a non-blocked read # >0 Perform a timed read sub ReadPipe () { # if data is not present in the pipe (STDIN), return an empty sting # if data is present, read until an EOF is detected, then return the # string, less the EOF mark my $Pipe = ""; my $Key = ""; ReadMode 4; # Turn off controls keys if ( defined ( $Key = ReadKey ( -1, \*STDIN ) ) ) { $Pipe = $Key; while ( ) { $Pipe .= $_ }; # reads until EOF detected } ReadMode 1; # Reset tty mode before exiting chomp ( $Pipe ); # print STDERR "\$Pipe = <$Pipe>\n"; return $Pipe; }