An interesting question, no? Would it be possible to redirect the output of an eval
'd statement that contains print
to a variable? I'm thinking along the lines of
my $hello='print "Goodbye System!"';
my $result=special_eval $hello;
print $results; # which would print "Goodbye System"
Oh, and it can't used a file for temporary storage (yes, it would be easy enough to redirect STDOUT to a /tmp/foobar.$$ file and snarf it back in, but this approach isn't possible in the actual situation).
For background, the purpose of this is to provide a mechanism for a person to write a Perl script that behaves the same whether you are running it from a command line or having a shell-type program execute it for you.