Welcome to Dream.In.Code
Become an Expert!

Join 150,356 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,913 people online right now. Registration is fast and FREE... Join Now!




Converting Fahrenheit to Celsius and vice versa

 
Reply to this topicStart new topic

Converting Fahrenheit to Celsius and vice versa

ladymuse
28 Jan, 2008 - 09:08 AM
Post #1

New D.I.C Head
*

Joined: 28 Jan, 2008
Posts: 2

My form should allow the user to enter the fahrenheit or celsius degrees in a text box. I have the html page with text boxes done, but once it's entered, the converted temp should be displayed on another Web page and that's the problem I'm having. I get a misconfiguration error. Hopefully I've explained this correctly.

Here's my code and errors:
CODE

#!usr/bin/perl
#c07case1.cgi- converts Fahrenheit/Celsius temps on a dynamic Web page
print "Content-type:text/html\n";
use CGI qw(:standard -debug);
use strict;

#declare variables
my ($fahr, $cels, $temp);

($fahr, $cels)=get_form_data();
$temp = calc_temp();
create_web_page();
exit;

****user-defined functions****
sub get_form_data {
return param('Temperature');
}#end get_form_data


sub calc_temp {
    my ($fahr,$cels);
    $fahr = $_[0];
    $cels = ($temp -= 32) * = 5/9;

    my ($fahr,$cels);
    $fahr = $_[0];
    $cels = ($fahr - 32) * 5/9;

    if ($fahr = "") {
        $temp = $cels;
return $cels
    }
    return Celsius;
    elseif ($cels = $fahr - 32) * 5/9) {
            $temp = $fahr;
return $fahr;  

    
} #end calc_temp



sub display_temp {
    print "<html>\n";
    print "<head><title>Washington Middle School</title></head>\n";
    print "<body>\n";
    print "$fahr degrees Fahrenheit is $cels degrees Celsius or
    print "$cels degrees Celsius is $fahr degrees Fahrenheit..\n";
    
    }
    print "</body></html>\n";
#end display_temp


Operator or semicolon missing before *user at c07.cgi line 15.
Ambiguous use of * resolved as operator * at c07.cgi line 15.
syntax error at c07.cgi line 16, near "sub get_form_data "
c07.cgi had compilation errors.
User is offlineProfile CardPM
+Quote Post

girasquid
RE: Converting Fahrenheit To Celsius And Vice Versa
28 Jan, 2008 - 10:38 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,296



Thanked: 18 times
Dream Kudos: 725
My Contributions
* is not a comment in Perl. Just #.
User is online!Profile CardPM
+Quote Post

KevinADC
RE: Converting Fahrenheit To Celsius And Vice Versa
28 Jan, 2008 - 04:34 PM
Post #3

D.I.C Head
Group Icon

Joined: 23 Jan, 2007
Posts: 238



Thanked: 6 times
Dream Kudos: 50
My Contributions
Your script has syntax errors, fix them and then try it again.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 12:45PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month