[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

10/28/2009 at 05:00PM PDT, ID: 24853109
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.7

Perl Help needed urgently

Asked by curiousPerl in Perl Programming Language, CGI Scripting

Tags: perl

Hello,
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
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
<!candle.html>
<HTML>
<HEAD><TITLE>Candles Unlimited</TITLE></HEAD>
<BODY>
<H1>Product Information</H1>
<FORM ACTION="http://yourservername/cgi-bin/chap09/c09ex5.cgi" METHOD=POST>
<P>Code: <INPUT TYPE=text NAME=Code></P>
<P>Name: <INPUT TYPE=text NAME=Name></P>
<P>Price: <INPUT TYPE=text NAME=Price></P>
<INPUT TYPE=submit Name=Button VALUE=Save>
<INPUT TYPE=submit Name=Button VALUE=Delete>
</FORM></BODY></HTML>
 
 
 
 
 
 
#!/usr/bin/perl
#c09ex5.cgi - saves data to and removes data from a database
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use SDBM_File;
use Fcntl;
use strict;
use warnings;
use diagnostics;
use CGI;
use CGI::Carp 'fatalsToBrowser';
 
#declare variables
my ($code, $name, $price, $button);
 
#assign values to variables
$code = param('Code');
$name = param('Name');
$price = param('Price');
$button = param('Button');
 
($code, $name, $price) = format_input();
 
if ($button eq "Save") {
   add();
}
elsif ($button eq "Delete") {
   remove();
}
exit;
 
#****user-defined functions*****
sub format_input {
   #declare and assign values to temporary variables
   my ($c, $n, $p);
   ($c, $n, $p) = ($code, $name, $price);
   #removes leading and trailing spaces
   $c =~ s/^ +//;
   $c =~ s/ +$//;
   $n =~ s/^ +//;
   $n =~ s/ +$//;
   $p =~ s/^ +//;
   $p =~ s/ +$//;
   #removes dollar sign
   $p =~ s/$//;
   #change to upper case
   $c =~ tr/a-z/A-Z/;
   $n =~ tr/a-z/A-Z/;
   return $c, $n, $p;
}
 
sub add {
   #declare variable
   my %product;
 
   #open database, add record, close database
   tie(%product, "SDBM_File", "chap09/c09ex5", O_CREAT|O_RDWR, 0666)
or die "Error opening chap09/c09ex5. $!, stopped";
   $product{$code} = $name, $price;
   untie(%product);
 
   #create web page
   print "<HTML>\n";
   print "<HEAD><TITLE>Candles Unlimited</TITLE></HEAD>\n";
   print "<BODY>\n";
   print "<H1>Candles Unlimited</H1>\n";
   print "The $name product has been added to the database.<BR>\n";
   print "</BODY></HTML>\n";
}
sub remove {
   #declare variables
   my (%product, $msg, %dummy);
 
#open database
   tie(%product, "SDBM_File", "chap09/c09ex5", O_RDWR, 0)
       or die "Error opening chap09/c09ex5. $!, stopped";
 
   #determine if information exists in database
  %dummy = %product;
   if (exists($dummy{$code})) {
       delete($product{$code});
       $msg = "The product has been deleted.";
   }
   else {
       $msg = "Product is not in database.";
   }
#close database
untie(%product);
 
#create web page
print "<HTML>\n";
print "<HEAD><TITLE>Candles Unlimited</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H1>Candles Unlimited</H1>\n";
print "$msg\n";
print "</BODY></HTML>\n";
}
[+][-]10/28/09 05:10 PM, ID: 25689490

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/09 05:13 PM, ID: 25689506

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/09 05:17 PM, ID: 25689531

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/09 05:53 PM, ID: 25689728

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/09 06:05 PM, ID: 25689800

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/09 07:35 PM, ID: 25690220

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/09 08:09 PM, ID: 25690371

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/29/09 06:29 AM, ID: 25693394

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/29/09 01:25 PM, ID: 25697878

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/29/09 03:15 PM, ID: 25698790

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/29/09 06:41 PM, ID: 25699657

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/30/09 03:36 AM, ID: 25701618

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Perl Programming Language, CGI Scripting
Tags: perl
Sign Up Now!
Solution Provided By: jdalberg
Participating Experts: 5
Solution Grade: A
 
 
 
Loading Advertisement...
20090824-EE-VQP-74 - Hierarchy / EE_QW_3_20080625