JStan
asked on
Cgi write to file
In my cgi scripts, I use code like
###################
print<<HTML;
blah,blah
HTML
####################
to print to a web page.
Is it possible to use similar code to write to a file.??
Rather than
print...
print...
over and over again.
Thanks in advance,
Jim
###################
print<<HTML;
blah,blah
HTML
####################
to print to a web page.
Is it possible to use similar code to write to a file.??
Rather than
print...
print...
over and over again.
Thanks in advance,
Jim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the quick reply
Jim
Jim
lets say you want to write to a file (/tmp/out.txt)
open(tmp, ">/tmp/out.txt") || die $!;
## You can change the currently selected filehandle with the select function.
## This function takes a single filehandle (or a scalar
## variable containing the name of a filehandle) as an argument. Once the ## currently selected filehandle is changed, it affects all
## future operations that depend on the currently selected filehandle.
select (tmp);
print<<HTML;
blah,blah
HTML
close(tmp);
## NOTE: The select operation is sticky; once you've selected a new handle, ## it stays in effect until the next select.
select (STDOUT);