Perl + Dreamweaver?

N

Nikos

Iam currently learning Perl and especially CGI.

I was wondering what is the best way to create a web interface in
conjuction with Perl so to avoid handcoding html?

Until no i use cgi.pm's module but its very dull writing stuff like this:

print start_form(-action=>'show.pl');
print table( {-border=>1, -width=>'60%', -align=>'center',
-style=>'border: ridge magenta; color: yellow; font-family: Times;
font-size: 18px', -background=>'../data/images/swirl.jpg'},
Tr( {-align=>'center'}, td( "Ðþò óå ëÝíå áäåëöÝ?" ),
td( textfield( 'onoma' ))),
Tr( {-align=>'center'}, td( "ÐïéÜ åßíáé ç ãíþìç óïõ ãéá ôçí åõ÷ïýëá
\"Êýñéå Éçóïý ×ñéóôÝ ÅëÝçóïí Ìå\"?"
), td( textarea( -name=>'euxoula', -rows=>4, -columns=>25 ))),
Tr( {-align=>'center'}, td( "ÌïéñÜóïõ ìáæß ìáò ìßá êáôÜ ôç ãíþìç óïõ
èáõìáóôÞ ðñïóùðéêÞ ðíåõìáôéêÞ åìðåéñßá
áðü êÜðïéïí ãÝñïíôá ðñïò þöåëïò ôùí
õðïëïßðùí áäåëöþí (áí öõóéêÜ Ý÷åéò
:)" ), td( textarea( -name=>'sxolio', -rows=>6, -columns=>25 ))),
Tr( {-align=>'center'}, td( "Ðïéü åßíáé ôï e-mail óïõ?" ),
td( textfield( 'email' ))),
Tr( {-align=>'center'}, td( submit( 'ÅìöÜíéóç üëùí ôùí áðüøåùí'
)), td( submit( 'ÁðïóôïëÞ' ))));
print end_form(), br(), br();


Perl + Dreamweaver?
 
L

Lord0

"its very dull writing stuff like this:"

I know this doesn't really answer your question but have a look at
HTML::Template
 
N

Nikos

Lord0 said:
"its very dull writing stuff like this:"

I know this doesn't really answer your question but have a look at
HTML::Template
What i want to do is "Separation of HTML and code".

I though that i can create my fancy hmtl page with dreamweaver and then
somehow(dont know how) join my code and html so they work together) Is
that possbile with dreamweaver? i must somehow create the html too...

If you please give a simple example of how can i simple perl script work
with html::template i would be grateful. I took a look at perldoc.com
but i didnt understand it.
 
S

Sherm Pendley

Nikos said:
I though that i can create my fancy hmtl page with dreamweaver and then
somehow(dont know how) join my code and html so they work together) Is
that possbile with dreamweaver?

The "joining together" part is what HTML::Template does.
If you please give a simple example of how can i simple perl script work
with html::template i would be grateful.

The synopsis at the top of the docs for HTML::Template includes a simple
example. You might also want to have a look at the articles at the web site:

<http://html-template.sourceforge.net/>

sherm--
 
G

Gunnar Hjalmarsson

Nikos said:
What i want to do is "Separation of HTML and code".

That's what HTML::Template, or any templating system, would help you with.
I though that i can create my fancy hmtl page with dreamweaver and then
somehow(dont know how) join my code and html so they work together) Is
that possbile with dreamweaver? i must somehow create the html too...

If you please give a simple example of how can i simple perl script work
with html::template i would be grateful. I took a look at perldoc.com
but i didnt understand it.

Even if HTML::Template is slightly more sophisticated, the example below
illustrates what the whole thing is about. Assume this in mytemplate.html:

<html><head><title>%HEADER%</title></head>
<body><h1>%HEADER%</h1>
<p>This is a %VAR1% for illustrating the
principles with a %VAR2%.</p>
</body></html>

and this CGI script:

#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;
my $q = CGI->new;
my %tmplvar = (
HEADER => 'My Template',
VAR1 => 'template',
VAR2 => 'templating system',
);
open my $tmpl, '<', 'mytemplate.html' or die $!;
my $output = do { local $/; <$tmpl> };
$output =~ s/%([^%\s]+)%/$tmplvar{$1} or "%$1%"/eg;
print $q->header, $output;
__END__

I don't use Dreamweaver, but I suppose that you can use it to edit such
a template to your liking.

HTH
 
N

Nikos

Gunnar Hjalmarsson wrote:

[snip]
I don't use Dreamweaver, but I suppose that you can use it to edit such
a template to your liking.

Thank you but it is still complicated.

In your opinion whats the easiest way of creating a Perl CGI Webpage and
why?

Perl + cgi.pm ? (the way i have it now)
Perl + Dreamweaver ?
Perl + Style Sheets ?

Iam really trying to fugure out the easiet method for implementing this.
cgi.pm is ok but it needs a lot of width, height, border, size,
font-family and stuff if you ahve it in a a index.pl that messes the
whole page up.
 
A

Andras Malatinszky

Nikos said:
What i want to do is "Separation of HTML and code".

I though that i can create my fancy hmtl page with dreamweaver and then
somehow(dont know how) join my code and html so they work together) Is
that possbile with dreamweaver? i must somehow create the html too...

If you please give a simple example of how can i simple perl script work
with html::template i would be grateful. I took a look at perldoc.com
but i didnt understand it.

Is it really PHP you are looking for?
 
G

Gunnar Hjalmarsson

Nikos said:
Gunnar Hjalmarsson wrote:

[snip]
I don't use Dreamweaver, but I suppose that you can use it to edit
such a template to your liking.

Thank you but it is still complicated.

In what way do you find that example complicated?

If you want to create web pages dynamically (which I suppose you do...),
you need to take the time to learn how to do it.
In your opinion whats the easiest way of creating a Perl CGI Webpage and
why?

Perl + cgi.pm ? (the way i have it now)

I like the idea of separating code and HTML, so I prefer templates
before CGI.pm's HTML generating stuff. And IMHO it's easier than using
CGI.pm.
Perl + Dreamweaver ?

Dreamweaver is just an HTML editor, isn't it?
Perl + Style Sheets ?

What have style sheets to do with dynamic web content?? Or isn't that
what you want?
 
T

Tor Fuglerud

Iam really trying to fugure out the easiet method for implementing this.
cgi.pm is ok but it needs a lot of width, height, border, size,
font-family and stuff if you ahve it in a a index.pl that messes the whole
page up.

Try to put as much layout as posible in a stylesheet, that way you don't
have to give formating detail in the script.
(not much to do with perl but that's what I always do when using CGI.pm)
 
N

Nikos

Gunnar said:
Nikos wrote:
In what way do you find that example complicated?

The way you are passing/replacing the values from the perl file to the
variables in html page.
I didn't understnad it.
Dreamweaver is just an HTML editor, isn't it?

Well yes, but you can create hmtl web pages very fast with it and
without messing with the said:
What have style sheets to do with dynamic web content?? Or isn't that
what you want?

Yes dynamic contents is what i want.
 
A

Alan J. Flavell

Dreamweaver is just an HTML editor, isn't it?

My colleague who uses it seems to produce great gobs of CSS and
Javascript, so "no", it's not "just" an HTML editor.
What have style sheets to do with dynamic web content??

Of course, "dynamic" web content can mean at least three different
contradictory things. Well, at least four... Nobody expects...
 
G

Gunnar Hjalmarsson

Nikos said:
The way you are passing/replacing the values from the perl file to the
variables in html page.
I didn't understnad it.

I used Perl's s/// operator. If you use HTML::Template instead, you
don't need to bother about regular expressions and such.

Modified mytemplate.html:

<html><head><title><TMPL_VAR NAME=HEADER></title></head>
<body><h1><TMPL_VAR NAME=HEADER></h1>
<p>This is a <TMPL_VAR NAME=VAR1> for illustrating the
principles with a <TMPL_VAR NAME=VAR2>.</p>
</body></html>

Modified script:

#!/usr/bin/perl -T
use strict;
use warnings;
use HTML::Template;
use CGI;
my $q = CGI->new;
my $tmpl = HTML::Template->new(filename => 'mytemplate.html');
my %tmplvar = (
HEADER => 'My Template',
VAR1 => 'template',
VAR2 => 'templating system',
);
for my $var (keys %tmplvar) {
$tmpl->param( $var => $tmplvar{$var} );
}
print $q->header, $tmpl->output;
__END__
 
G

Gunnar Hjalmarsson

Alan said:
My colleague who uses it seems to produce great gobs of CSS and
Javascript, so "no", it's not "just" an HTML editor.
s/just/mostly/


Of course, "dynamic" web content can mean at least three different
contradictory things. Well, at least four... Nobody expects...

Well, as I know you understood, I had difficulties to understand how
style sheets could be an alternative to using templates or CGI.pm. Maybe
I could have expressed myself more clearly. :)
 
N

Nikos

Alan said:
My colleague who uses it seems to produce great gobs of CSS and
Javascript, so "no", it's not "just" an HTML editor.

How does he passes values to the pages he produces with Dreamweaver?
By using Dreamweaver?
 
S

Scott Bryce

Nikos said:
In your opinion whats the easiest way of creating a Perl CGI Webpage
and why?

Perl + cgi.pm ? (the way i have it now)
Perl + Dreamweaver ?
Perl + Style Sheets ?

CGI.pm, DreamWeaver and CSS do three very different things. Use the ones
that do the job you want to do. You will probably wind up using all
three for different aspects of this task.

I am really trying to fugure out the easiet method for implementing
this.

You have already been pointed to HTML::Template. That is probably the
easiest tool you will find to separate HTML from your Perl script. There
are other templating tools that will also work.

If there is something specific about HTML::Template that you don't
understand, please ask a specific question that will help clear up your
confusion.
 
S

Scott Bryce

Nikos said:
How does he passes values to the pages he produces with Dreamweaver?
By using Dreamweaver?

It is beginning to look like you don't really understand the process
well enough to understand how to use the tools available.

Come up with a short, simple example to try out. If you can't get it to
work, post what you tried, and we can help. Gunnar gave you a good
example to start with.

All you are doing now is telling us that you don't understand. We know
that, but it doesn't help us help you.
 
N

Nikos

Scott said:
CGI.pm, DreamWeaver and CSS do three very different things. Use the ones
that do the job you want to do. You will probably wind up using all
three for different aspects of this task.

One is enouph thank you! :)
You have already been pointed to HTML::Template. That is probably the
easiest tool you will find to separate HTML from your Perl script. There
are other templating tools that will also work.

If there is something specific about HTML::Template that you don't
understand, please ask a specific question that will help clear up your
confusion.

Can you please give the simplest example on html::template?
 
N

Nikos

Scott said:
It is beginning to look like you don't really understand the process
well enough to understand how to use the tools available.

Come up with a short, simple example to try out. If you can't get it to
work, post what you tried, and we can help. Gunnar gave you a good
example to start with.

All you are doing now is telling us that you don't understand. We know
that, but it doesn't help us help you.

Yes that is correct, i will try make somethign on my own to simplify
Gunnars example to something very easy and if i cant get it to work i
will post it here. Iam on to that now.

You are right. I must try that to see what *exactly* is what i dont
understand.
 
A

Alan J. Flavell

s/just/mostly/

OK, pax...
Well, as I know you understood, I had difficulties to understand how
style sheets could be an alternative to using templates or CGI.pm.

Sure, no offence to your main point, I was just heckling on a
side-issue that you'd raised.

all the best
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top