still doesnt work :-(
Main Topics
Browse All TopicsHello,
I am teaching myself perl and I cant seem to get this to work, at all. I am getting a server error and even though I have the print fatals to browser I am still getting the server configuration issue. Here is the html and cgi code is below: Any help or suggestions is welcome. I have three others issues but I will post them individually. My experience with perl is limited so I welcome any help. Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Well, if you run it from the command line, you do gets lots of useful info (warnings, that will give you an internal server error)
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Useless use of private variable in void context at c09ex5.cgi line 59.
Content-type: text/html
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 38.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 39.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 40.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 41.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 42.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 43.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 45.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in substitution (s///) at c09ex5.cgi line 45.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in transliteration (tr///) at c09ex5.cgi line 47.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in transliteration (tr///) at c09ex5.cgi line 48.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in string eq at c09ex5.cgi line 24.
[Wed Oct 28 18:45:51 2009] c09ex5.cgi: Use of uninitialized value in string eq at c09ex5.cgi line 24.
Simplistically, you could comment the
use warnings;
line to make it work, but that's a little like turning up the stereo in your car to drown out the clunking noises coming from the engine.
Most of the warnings are produced by not having any input when running from the command line, so they can be ignored. The critical warning (and the one producing the internal server error) is:
c09ex5.cgi: Useless use of private variable in void context at c09ex5.cgi line 59.
as this comes before the HTTP header.
To fix this, you need to change
$product{$code} = $name, $price;
to
$product{$code} = "$name, $price";
I also note that you should learn to not use global variables.
If you have made the corrections so that it runs properly from the command line,
then it may be a server issue.
Are you able to run a simple perl script contai ning only
#!/usr/bin/perl
#c09ex5.cgi - saves data to and removes data from a database
print "Content-type: text/html\n\n";
if not, have you checked the basic configuration issues listed in
http://www.perl.org/troubl
I have changed some things around and at least now I am getting some helpful warnings. The new code is below and the error message I am getting is:
Error opening c09ex5. Permission denied, stopped at /c09ex5.cgi line 50
Which is odd because the permissions is set to 666 which is correct. Please help me anyone. Thanks!
Does the file exist? The 0666 permissions here are used when creating the file. If the file does not already exist, then the webserver (user running this script) needs write access to the directory. Does this user have write access to the directory?
You also don't specify the directory when you name the file. When the webserver executes this file, you have no guarantees as to what the current directory is. Specify the full absolute path to the file.
try writing the file to /tmp
Remember that umasks are probably in place, so if the user running the httpd process, i.e. the www or the nobody user probably has umask in effect. You can set it in perl using "umask 0000;", for instance, which would make sure that your file actually gets 0666 when created.
If it works in /tmp, have a look at permissions on the directory where you want the file created, hey should allow the www user to write. So if its owned by someuser:somegroup, and set to 755, then only someuser can create files there. if you change it to 775 and make www a member of somegroup, that user should be able to create files there.
Business Accounts
Answer for Membership
by: mrjoltcolaPosted on 2009-10-28 at 17:10:10ID: 25689490
Try running the CGI program from the command line. That will show you if it has syntax errors (likely) or not. That is the most common reason for "internal server error" that I recall.