use IO::Select qw( ); sockify_stdin(); my $stdin_buf = ''; my $sel = IO::Select->new(*STDIN); while (my (@ready) = $sel->can_read()) { my $rv = sysread(*STDIN, $stdin_buf, 64*1024, length($stdin_buf)); die if !defined($rv); last if !$rv; while ($stdin_buf =~ s/(.*\n)//g) { print "$1"; } } print "$stdin_buf\n" if length($stdin_buf);