Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I want to construct the STDIN for a program that I call with the "system" command. I am working on perl 5.8.0.
I've put an idiot version of the code below (Notice the print in the middle.)
Any help would be appreciated.use strict; # Read all the data from STDIN in the $buffer variable my $buffer = do { local $/; <STDIN> }; #Do a subtitution. $buffer =~s/essage/assage/sg; # Put $buffer back in STDIN so our system call can read it. # DOES NOT WORK. print STDIN "$buffer"; # Call our second program. unshift(ARGV,"printout.pl"); unshift(ARGV,"perl"); system @ARGV;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Constructing STDIN for an external progam
by Ovid (Cardinal) on Sep 11, 2006 at 12:02 UTC | |
by Thelonius (Priest) on Sep 11, 2006 at 15:24 UTC | |
by ikegami (Patriarch) on Sep 11, 2006 at 17:27 UTC | |
|
Re: Constructing STDIN for an external progam
by xdg (Monsignor) on Sep 11, 2006 at 14:33 UTC | |
|
Re: Constructing STDIN for an external progam
by davorg (Chancellor) on Sep 11, 2006 at 12:04 UTC |