#!/usr/bin/perl

use strict;
use warnings;

my ($rin, $win, $ein) = ('', '', '');
vec($rin, fileno(STDIN),1) = 1;
$ein = $rin | $win;

my ($rout, $wout, $eout);
my $timeout = 1;
while(1) {
	my $nfound = select( $rout = $rin, $wout = $win, $eout = $ein, $timeout );
	if( $nfound == 0 ) {
		# timeout, print \n and increase timer
		print "\n";
		$timeout *= 2;
	} else {
		my $buf;
		my $rv = sysread STDIN, $buf, 4096;
		if( $rv == 0 ) {
			# EOF
			exit 0;
		} elsif( ! defined $rv ) {
			# error
			exit 1;
		}
		print $buf;
		$timeout = 1;
	}
}
