G+_Joe Maruschek Posted July 23, 2014 Share Posted July 23, 2014 Here's an example web form-based perl script. This time, it's just a simple calculator. You can see it in action on my site at http://joemaruschek.com/test/web_calc.pl. I designed the script to draw the empty form and also receive data from the form, which is a little different than what Patrick showed us where he had a separate HTML file with the form. Instead of just printing the results, I put the received values back in the form so you can change something and submit it again. I also used some different forms of the IF statement, where I put everything on one line to make things clear and less cluttered. I also used a version of the IF statement that they haven't shown us yet where you can place the IF condition AFTER the statement that usually goes inside the brackets. Sometimes it just makes things clearer when you use that form. https://github.com/joemarus/perl_examples/blob/master/web_calc.pl Link to comment Share on other sites More sharing options...
G+_Joe C. Hecht Posted July 23, 2014 Share Posted July 23, 2014 Cute :) It even seems well behaved when you input a divide by zero (although I am thinking my error log may have grown a bit), and I would have guessed that 'A' + 1 would have resulted in 66 (although I must admit I only took a brief look at the code). Nice submission. Link to comment Share on other sites More sharing options...
G+_Joe Maruschek Posted July 23, 2014 Author Share Posted July 23, 2014 Joe Hecht Yeah, that first version didn't have much error-checking. I just posted an update that's a little better. Link to comment Share on other sites More sharing options...
Recommended Posts