Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Tecnique and/or Modules for Perl and HTML

Reply
Thread Tools

Tecnique and/or Modules for Perl and HTML

 
 
pgodfrin
Guest
Posts: n/a
 
      03-01-2008
Greetings,

Could someone point me in the right direction? I'm not a web developer
- just a budding perl dude (who's really a database guy).

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

There is a bunch of confusing stuff out there everything from
javascript to embperl and then Mason. And the unspeakable PHP of
course...

Can anyone offer some advice where I should go? (ok - no wisecracks...
<grin>)

thanks,
pg
 
Reply With Quote
 
 
 
 
Ron Bergin
Guest
Posts: n/a
 
      03-01-2008
On Mar 1, 7:42 am, pgodfrin <pgodf...@gmail.com> wrote:
> Greetings,
>
> Could someone point me in the right direction? I'm not a web developer
> - just a budding perl dude (who's really a database guy).
>
> 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
>
> There is a bunch of confusing stuff out there everything from
> javascript to embperl and then Mason. And the unspeakable PHP of
> course...
>
> Can anyone offer some advice where I should go? (ok - no wisecracks...
> <grin>)
>
> thanks,
> pg


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
 
Reply With Quote
 
 
 
 
Ron Bergin
Guest
Posts: n/a
 
      03-01-2008
On Mar 1, 7:42 am, pgodfrin <pgodf...@gmail.com> wrote:
> Greetings,
>
> Could someone point me in the right direction? I'm not a web developer
> - just a budding perl dude (who's really a database guy).
>
> 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
>
> There is a bunch of confusing stuff out there everything from
> javascript to embperl and then Mason. And the unspeakable PHP of
> course...
>
> Can anyone offer some advice where I should go? (ok - no wisecracks...
> <grin>)
>
> thanks,
> pg


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
 
Reply With Quote
 
pgodfrin
Guest
Posts: n/a
 
      03-01-2008
On Mar 1, 10:42 am, Ron Bergin <r...@i.frys.com> wrote:
> On Mar 1, 7:42 am, pgodfrin <pgodf...@gmail.com> wrote:
>
>
>
> > Greetings,

>
> > Could someone point me in the right direction? I'm not a web developer
> > - just a budding perl dude (who's really a database guy).

>
> > 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

>
> > There is a bunch of confusing stuff out there everything from
> > javascript to embperl and then Mason. And the unspeakable PHP of
> > course...

>
> > Can anyone offer some advice where I should go? (ok - no wisecracks...
> > <grin>)

>
> > thanks,
> > pg

>
> 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.

I'm not having a problem per se, but a conceptual quagmire - I have a
web page, I just want to slap a table or text box in the middle of it
with data from a perl DBI query. Maybe that's not how you do it...
pg
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      03-01-2008

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

 
Reply With Quote
 
pgodfrin
Guest
Posts: n/a
 
      03-01-2008
On Mar 1, 1:29 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth pgodfrin <pgodf...@gmail.com>:
>
>
>
> > 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


Hi Ben,
Always good to hear from you. I feel like - forgive the expression -
you're my fairy godmother... <grin>

I will read the docs a little closer - I must have been looking for a
silver bullet and peeked at the doc in a somewhat lazy manner.

thanks, as always,
pg
 
Reply With Quote
 
pgodfrin
Guest
Posts: n/a
 
      03-02-2008
On Mar 1, 4:36 pm, pgodfrin <pgodf...@gmail.com> wrote:
> On Mar 1, 1:29 pm, Ben Morrow <b...@morrow.me.uk> wrote:
>
>
>
> > Quoth pgodfrin <pgodf...@gmail.com>:

>
> > > 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

>
> Hi Ben,
> Always good to hear from you. I feel like - forgive the expression -
> you're my fairy godmother... <grin>
>
> I will read the docs a little closer - I must have been looking for a
> silver bullet and peeked at the doc in a somewhat lazy manner.
>
> thanks, as always,
> pg


sim-sala-bim...

I have seen the light...

I think I'm gonna start calling you Yoda...

pg
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can perl modules be used by various versions of perl? garey Perl Misc 3 05-29-2007 07:01 AM
Perl Multithreading and use of Perl Modules Nate Perl Misc 8 07-07-2005 05:33 PM
C++ inlining as a multithreading optimization tecnique? gianguz C++ 10 12-14-2004 09:27 PM
Merge tecnique with XSL JohnPlayerSpecial XML 0 04-27-2004 04:55 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57