Solved

Cgi write to file

Posted on 2000-05-04
3
154 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:JStan
3 Comments
 
LVL 2

Accepted Solution

by:
mattrope earned 50 total points
Comment Utility
Yeah, just use:

print FILEHANDLE <<ENDLABEL;
blah
blah2
ENDLABEL

That should do it.
0
 
LVL 16

Expert Comment

by:maneshr
Comment Utility
sure you can do that.

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);

0
 

Author Comment

by:JStan
Comment Utility
Thanks for the quick reply
Jim
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now