File: synopsis_scripting

package info (click to toggle)
libipc-run-perl 0.92-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 736 kB
  • sloc: perl: 5,738; makefile: 5
file content (25 lines) | stat: -rw-r--r-- 623 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl -w
use strict ;

my @cat = qw( cat ) ;
my ( $in_q, $out_q, $err_q ) ;

use IPC::Run qw( start pump finish timeout ) ;

# Incrementally read from / write to scalars.  Note that $in_q
# is a queue that is drained as it is used. $h is for "harness".
my $h = start \@cat, \$in_q, \$out_q, \$err_q, timeout( 10 ), debug => 1 ;

$in_q .= "some input\n" ;
pump $h until $out_q =~ /input\n/g ;

$in_q .= "some more input\n" ;
pump $h until $out_q =~ /\G.*more input\n/ ;

$in_q .= "some final input\n" ;
finish $h or die "cat returned $?" ;

warn $err_q if $err_q ; 
print $out_q ;         ## All of cat's output