in reply to How to call a script interactively from perl
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; #interface to "units" calculator #my $pid = open3(\*WRITE, \*READ, \*ERROR,"units -t"); #terse output my $pid = open3(\*WRITE, \*READ, 0 , "units -t"); #if \*ERROR is set to 0, STDERR is sent to STDOUT #chomp(my $prompt = <READ>); #print "$prompt\n"; foreach ( '100 yards', '1 mile', '1 kilometer', '1 parsec', '1 foobar' +){ print WRITE "$_\n meters \n"; chomp(my $answer = <READ>); print "$_ = $answer meters\n"; } __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to call a script interactively from perl
by LetMeAsk (Initiate) on Oct 15, 2012 at 21:14 UTC | |
by zentara (Cardinal) on Oct 16, 2012 at 11:07 UTC | |
by LetMeAsk (Initiate) on Oct 16, 2012 at 14:34 UTC | |
by McA (Priest) on Oct 16, 2012 at 14:44 UTC | |
by LetMeAsk (Initiate) on Oct 16, 2012 at 16:26 UTC |