Debian Codegraph @

examples/test-booldnf.pl

raw
1 #!/usr/bin/perl -w
2 #
3 # $Id: test-booldnf.pl,v 1.3 2005/02/03 23:26:43 sarrazip Exp $
4 #
5 # Example of bidirectional pipes to talk to the booldnf(1) command
6 # from a Perl script.
7 #
8 # Written by Pierre Sarrazin <http://sarrazip.com/>
9 # This file is in the public domain.
10 #
11
12 use strict;
13 use IPC::Open2;
14
15
16 my $command = shift || "booldnf";
17 my ($reader, $writer);
18 my $pid = open2($reader, $writer, $command);
19 if (!defined $pid)
20 {
21 print "open2: $command: $!\n";
22 exit 1;
23 }
24
25 while (<>)
26 {
27 print $writer $_;
28 my $response = <$reader>;
29 print "Response: $response";
30 }
31
32 close $reader;
33 close $writer;
34 waitpid $pid, 0; # see the IPC::Open2 manual page.