in reply to Re: Splitting output
in thread Splitting output

Just to add to dmm's code. If you don't really care about scrolling and buffering the output, you could use this for the write to window:
#!/usr/local/bin/perl -w # Something like this: use IO::Select; use Curses; my $win = new Curses; my $x = $win->getmaxx; my $y = $win->getmaxy; my $m = int( $y/2 ); my $r = $x-2; my $div = "-"x$r; my $one_s = 1; my $one_e = $m-1; my $two_s = $m+1; my $two_e = $y-2; $win->box( '|', '-' ); $win->addstr( $m, 1, $div ); $win->refresh; my $bladeenc_cmd = 'bladeenc -whatever args'; my $cdparanoia_cmd = 'cdparanoia -whatever else args'; open P1, "$bladeenc_cmd|" or die "bladeenc: $!"; open P2, "$cdparanoia_cmd|" or die "cdparanoia: $!"; local $SIG{PIPE} = sub { warn "pipe closed"; }; my $s = IO::Select->new(); my $timeout = 100; # msec(?) $s->add(\*P1); $s->add(\*P2); my $one_cnt = $one_s; my $two_cnt = $two_s; my @ready; while (@ready = $s->can_read($timeout)) { foreach my $fh (@ready) { if ($fh == \*P1) { my $line = <$fh>; if( $line ) { $win->addstr( $one_cnt, 1, $line ); $one_cnt++; $one_cnt = $one_s if $one_cnt > $one_e; $win->refresh; } } if ($fh == \*P2) { my $line = <$fh>; if( $line ) { $win->addstr( $two_cnt, 1, $line ); $two_cnt++; $two_cnt = $two_s if $two_cnt > $two_e; $win->refresh; } } } }

It's not pretty but it does work.

derby