Quid has asked for the wisdom of the Perl Monks concerning the following question:

Hello all, I just made my first (extremely) basic script which calculates area of polygons. The user should be able to enter the radius and number of sides of the polygon in a form, then have the area calculated. The script works fine when you type in, say, $radius = 5;. But, I want the 5 to come from the form. When I make a simple form, named "text1", I am able to get that value onto the script. But, it looks something like this ($buffer is data from form): text1=5. Obviously, I cannot multiply text1=5 times five. I want just the number from the form. Thanks.

#!C:\Perl\bin\perl #Temporary Variables -Would normally be from form by user $radius = 12; $numsides = 10; $cangle = 180/$numsides; $pi = 3.141592654; $halfside = $radius*sin($cangle*$pi/180); $apothem = $radius*cos($cangle*$pi/180); $area = $halfside*$apothem*$numsides; print "Content-type:text/html\n\n"; print "<html>\n"; print "Area is $area"; print " when radius is $radius and there are $numsides sides."; print "</html>\n";</p>

Replies are listed 'Best First'.
Re: Post forms & sending data
by exussum0 (Vicar) on May 11, 2004 at 02:46 UTC