http://qs321.pair.com?node_id=390317

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:

# 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
My program seems to hang at the  while(<>). Thanks for advice, great monks!

water