afroncio has asked for the wisdom of the Perl Monks concerning the following question:
-----buff1.pl-----% ./buff1.pl | ./buff2.pl (out of memory)
------ end buff1.pl ------------------------ ------- buff2.pl ------------------------#!/usr/bin/perl use strict; use FileHandle; my $tslast = ""; while( 1 == 1 ) { my $timestamp = time(); if( $timestamp ne $tslast ) { my $ofh = select STDOUT; $| = 1; select $ofh; $ofh->autoflush(1); print STDOUT $timestamp . "\n"; $tslast = $timestamp; } }
------ end buff2.pl ---------------#!/usr/bin/perl use FileHandle; foreach my $line ( <STDIN> ) { my $ofh = select STDOUT; $| = 1; select $ofh; $ofh->autoflush(1); print STDOUT $line; }
How can I remove buffering so that buff2.pl spits out my timestamps?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stop buffering on STDOUT
by jwkrahn (Abbot) on Nov 01, 2009 at 17:12 UTC | |
by afroncio (Novice) on Nov 01, 2009 at 17:16 UTC | |
|
Re: Stop buffering on STDOUT
by b0at (Novice) on Nov 01, 2009 at 17:17 UTC | |
|
Re: Stop buffering on STDOUT
by biohisham (Priest) on Nov 01, 2009 at 17:29 UTC |