water has asked for the wisdom of the Perl Monks concerning the following question:
Is is possible to tie STDIN/STDOUT using IO::Scalar such that an mini-program run via an eval statement would, when using STDIN and STDOUT, actually be reading and writing strings? This snippet gives the sense of what I'm trying to do:
My program seems to hang at the while(<>). Thanks for advice, great monks!# untested my $code = 'while (<>) { print; }'; # would typically be more interest +ing my $output = ''; # storage for output my $input = "more and more\nstuff here"; # would typically be more int +eresting { tie *STDIN, 'IO::Scalar', \$input; tie *STDOUT, 'IO::Scalar', \$output; eval "$code"; } # interesting stuff should be in output here
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: tieing STDIN & STDOUT using IO::Scalar for use inside an eval
by ikegami (Patriarch) on Sep 11, 2004 at 21:41 UTC | |
Re: tieing STDIN & STDOUT using IO::Scalar for use inside an eval
by water (Deacon) on Sep 11, 2004 at 21:45 UTC | |
by dave_the_m (Monsignor) on Sep 11, 2004 at 21:55 UTC | |
by etcshadow (Priest) on Sep 11, 2004 at 22:24 UTC | |
by edan (Curate) on Sep 12, 2004 at 11:51 UTC |
Back to
Seekers of Perl Wisdom