in reply to How to get data from a web page.

Here's two ways* I would consider (there are pros and cons to each):

1. HTML and Javascript (fast, client-side, but 10%± have JS turned off):

First number: <input type="text" id="num1" /> Second number: <input type="text" id="num2" /> Your answer: <input type="text" id="answer" /> Add them: <input type="button" value="Add" onclick="addthem();" />

or HTML for CGI handling, change last lines to:

Your answer: <input type="text" id="answer" value="<tmpl_var answer>" /> <input type="submit" value="Add" />

Javascript:

function addthem() { var num1 = document.getElementById("num1"); var num2 = document.getElementById("num2"); var answer = num1 + num2; document.getElementById("answer").value = answer; }

2. CGI and HTML::Template (doesn't require JS, but does require a module and a round robin to the server):

use HTML::Template; use CGI; my $query = new CGI; my $num1 = $query->param('num1'); my $num2 = $query->param('num2'); my $template = HTML::Template -> new(filename => "addnumbers.tmpl"); $template->param( answer => $num1 + $num2 ) print "Content-type: text/html\n\n"; print $template->output();
*all code is untested

—Brad
"Don't ever take a fence down until you know the reason it was put up. " G. K. Chesterton