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>
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.