awohld has asked for the wisdom of the Perl Monks concerning the following question:
If I want to write to a command using a filehandle and not see the resulting output I do this:my $output = `command <<EOF; yes EOF`; # print output from `command` after giving it 'yes' as input print $output . "\n";
But what do I do if I want to write to the command as easily as using a file handle and read whatever comes back as easily as a scalar? Essentially I want to do both of the examples above at the same time.open(COMMAND, '| command') or die("Can't run command: $!\n"); # give program 'yes' as input print COMMAND 'yes';
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Interactively Read / Write to Program
by ikegami (Patriarch) on Jun 29, 2009 at 23:34 UTC | |
Re: Interactively Read / Write to Program
by Fletch (Bishop) on Jun 30, 2009 at 00:31 UTC | |
Re: Interactively Read / Write to Program
by rovf (Priest) on Jun 30, 2009 at 10:32 UTC | |
by afoken (Chancellor) on Jun 30, 2009 at 11:23 UTC | |
by rovf (Priest) on Jun 30, 2009 at 13:02 UTC |