I'm stuck on a coding issue and was hoping someone in this forum might have some insight.
I'm trying to redirect my cgi script (perl) output to a variable, store it all in the database, and then switch the output back to normal and output the page to the web browser.
I am able to switch the output to my variable and store it in my database, but I cannot for the life of me figure out how to switch the output back to normal so I can write back to the user's web browser?
Here is my code:
# First I close STDOUT, then re-assign it to my variable $dbout...
$dbout = STDOUT;
close STDOUT;
open STDOUT, '>&', \$dbout or die "Can't open STDOUT: $!";
# Now I have my cgi/perl script run and generate the webpage output... which now gets dumped into my variable $dbout
print "<HTML>";
print "...";
print "</HTML>";
# Once the page is saved in the DB... I have no idea how to switch it back so that my "print" statements go back to normal and not to the $dbout variable?!?
I've tried 100 variations of code I found in various man pages, etc. Nothing seems to work. Any ideas or suggestions would be GREATLY appreciated... ;-)
Thanks!