Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating text files in perl

Status
Not open for further replies.

pseudosig

Technical User
Mar 3, 2004
4
US
I just started writing cgi's for the web and I'm need to know how I can create a text file dynamically through my cgi script (to store data later) instead of having to create it by hand (statically).

I've thumbed through sever perl/cgi books and none make mention of this (they just tell how to read/write to a file).

Thanks in advance,
Pseudosig
 
More information please. CGI is perl and you use read/write functions (just like your texts talked about) to create text files. How does read/write not fit your needs?
 
CGI is not perl...it's Common Gateway Interface. I've written cgi's in c/c++ etc etc... cgi is a super set interface which emcompasses many programming languages.

Anywho, I will (and do) utilize read/write functions in my scripts. But see, I need to be able to create a text file in my script on the fly, to then write to it (to store form data, etc etc...). But I don't know how to create one in my script. Thus far I can only create a text file during a unix terminal session. But I need my script to be more dynamic than that.

Thanks again,
Pseudosig
 
Over tradition, CGI was the extension usually used FOR perl. People still do so today and C/C++ is now most commonly used as modules in perl.
 
CGI..Perl..C++... Okay.....


I still don't see why you are having a problem. When you open a filehandle for writing with perl, it automatically creates the file. Just stick the filehandle in your logic where you want it to be created at.

open (OUT, ">file.txt");

You know have an open filehandle and can print to it at any point in time by saying:

print OUT "your text goes here";


Do you have some sample code you can show along with instructions on where you want the text file creation command to be placed and how you want text to be written to the file?

 
rak,

you're letting it get to you ....

breathe ....

4 is better than three
 
lol...thanks for a laugh. The last few days have been stressful. Have spent over 6 hours on the phone with Toshiba technical support trying to get resolution to a (should be) simple problem, but not even level 3 support knows the answer. It has really had my ire up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top