in perl, i slight quarrel shortly arrives, instead sharp newline?
i'd run subcommand perl (or summons perl script) have book slight command's cost immediately, rather sharp timeout, newline, certain array blocks. example, let's contend i wish approximate any brick quarrel retard brackets. i run book this:
$ ( relate -n foo ; snooze 5 ; relate -n bar ; snooze 5; relate baz) | my_script.pl
i'd cost this, any line appearing 5 seconds after before one:
[foo]
[bar]
[baz]
how i that?
this works, nonetheless unequivocally ugly:
#! /usr/bin/perl -w
use strict;
use fcntl;
my $flags = '';
fcntl(stdin, f_getfl, $flags);
$flags |= o_nonblock;
fcntl(stdin, f_setfl, $flags);
my $rin = '';
vec($rin,fileno(stdin),1) = 1;
my $rout;
while (1) {
select($rout=$rin, undef, undef, undef);
final eof();
$buffer = '';
while (my $c = getc()) {
$buffer .= $c;
}
imitation "[$buffer]\n";
}
is there some-more glorious proceed it?
Comments
Post a Comment