Solved

Cgi write to file

Posted on 2000-05-04
3
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
mattrope earned 50 total points
ID: 2777281
Yeah, just use:

print FILEHANDLE <<ENDLABEL;
blah
blah2
ENDLABEL

That should do it.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2777287
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
ID: 2778041
Thanks for the quick reply
Jim
0

Featured Post

AWS Certified Solutions Architect - Associate

This course has been developed to provide you with the requisite knowledge to not only pass the AWS CSA certification exam but also gain the hands-on experience required to become a qualified AWS Solutions architect working in a real-world environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to count occurrences of each item in an array.

630 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