Quoth pgodfrin <>:
> On Mar 1, 10:42 am, Ron Bergin <r...@i.frys.com> wrote:
> > On Mar 1, 7:42 am, pgodfrin <pgodf...@gmail.com> wrote:
> >
> > > I'd like to (at first) read from database (using DBI) and display the
> > > contents on a web page. The trick is I want to do it on the same page
> > > that the action button resides and pop the output of the perl program
> > > into a scrollable box. Nothing fancy - just output some data from a
> > > database call. Eventually I'd like to be able to pass variables from a
> > > form to the waiting perl program
> >
> > Have you looked at the CGI module? The synopsis section will give you
> > a hint on part of what you need. By the time you finish reading the
> > doc, you should have a pretty good idea where to start. After you've
> > made an attempt, post back with specific questions and example code
> > that demonstrates the problem that you're
> having.http://search.cpan.org/~lds/CGI.pm-3.33/CGI.pm
>
> Yep - I've even run the samples. Perhaps it's a conceptual thing, but
> it seems to me that the CGI module is all encompassing. When it's run
> - it must produce the entire web page. Which is not what I think I
> want.
It is, though

. Except for modern JS-based techniques like Ajax, which
I would suggest you avoid for now, the way the web works is whole pages
at a time. If you re-read the docs for CGI.pm, you will find it has lots
of methods for re-requesting the current page with something slightly
different, and for preserving your program's state across several
invocations of the 'same' page.
Try this. It's not necessarily a good example of how to use CGI, the
HTML-generation is very simple-minded, and of course passing anything
to 'eval' is just downright stupid; but it should give you an idea of
how such programs work.
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;
my $Q = CGI->new;
my $url = $Q->url;
print $Q->header;
print <<HTML;
<html>
<head><title>Calculator</title></head>
<body>
<h2>Enter an arithmetic expression:</h2>
<form action="$url" method="POST">
<input name="eval"> <input type="submit" value="Eval">
</form>
HTML
if (my $expr = $Q->param('eval')) {
print <<HTML;
<!-- $expr -->
HTML
if (my ($safe) = $expr =~ m{^([-+/*()\d. ]+)$}) {
my $val = eval $safe;
if (defined $val) {
print <<HTML;
<p>Result: $val.</p>
HTML
}
else {
print <<HTML;
<p style="color: red;">Syntax error: $@</p>
HTML
}
}
else {
print <<HTML;
<p style="color: red;">Bad input.</p>
HTML
}
}
print <<HTML;
</body>
</html>
HTML
__END__
Ben