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
Back to
Seekers of Perl Wisdom