Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


using perl to create files

This topic is 5527 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''m trying to write a CGI script that will take a username and create a new data file that is the "username.txt" so that it can write the data for that user. I use the open command in Perl $cfilename = $username.".txt"; open(UFILE, ">$cfilename"); # do stuff the open command is supposed to create a file if it does not exist, but when I look in the directory, there is no new file created. I read some hints that I would have to change the permissions of my cgi-bin directory to allow the script to create new files in the directory, however, I tried setting different permissions and didn''t run into anything that worked. has anyone else had this problem before and can tell me how I can fix it? thanks in advance.

Share this post

Link to post
Share on other sites
Check if open fails or so.

open(UFILE, ">$cfilename") or die "$!";

The $! variable holds an error message which is set by open if it fails. If you run it as a CGI script through a web page, the message should show up in the web server error log (that''s what it does for me, using Apache).

Share this post

Link to post
Share on other sites
nope, for some reason if I check to see if it works, as in

if (open(blah blah blah))
# do file code
# display error message

it always does the file code even if the file wasn''t created. no error messages come up in the logs, just no file being created.

written as a perl file and ran in windows, it works fine. but CGI under Linux, it doesn''t.

c''mon guys, keep me from turning over to the dark side of Windows, keep me using Linux.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!