Perl + Dreamweaver?

N

Nikos

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.

Here it is:
=================================
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI qw:)standard);


$number = int(rand(10)) + 1;
$name = "Nikos";
$day = "Tuesday";

open(FH, "<test.html") or die $!;

print $number, $name, $day;

==================================
<html>

<head>
<title>Today is $day!</title>
</head>


<body>

<h1>Hello $name, how are are you today?</h1>
<p>This is a random number generator: $number</p>

</body>

</html>
===================================


By making this simple script myself i have understanded that i dont know
how to pass the values from test.pl to test.html so that in runtime of
etst.html $number, $day and $name be replaced with a random number,
"tuesday" and "Nikos". In other words i dont know how to merge those 2
scripts.

Instead of that as i have it now i am just getting an output to the
console when i run perl test.pl.
 
S

Scott Bryce

Nikos said:
One is enouph thank you! :)

No. They are three different tools that do three different things. You
will use all three. Just like a carpenter uses a saw to cut wood, a
hammer to pound nails, and a tape measure to take measurments. You
cannot create dynamic web pages with JUST CSS or JUST CGI.pm or JUST an
HTML editor any more than a carpenter can build a house with JUST a hammer.
Can you please give the simplest example on html::template?

Gunnar already did. Or you can start with the example in the docs.

http://search.cpan.org/~samtregar/HTML-Template-2.7/Template.pm
 
S

Scott Bryce

Nikos said:
Here it is:

<code snipped>

And here it is using HTML::Template. Note that this simply sends output
to the console. I will leave it to you to build this into a CGI application.

Though this example does not make use of CGI.pm, I left the use
statements in, assuming that you will expand this into a script that
makes use of CGI.pm.

FWIW, All I did was start with your code, and copy the relevant changes
directly from the docs, with appropriate tweaks.

---------

#!/usr/bin/perl
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw:)standard);
use HTML::Template;

my $number = int(rand(10)) + 1;
my $name = "Nikos";
my $day = "Tuesday";

my $template = HTML::Template->new(filename => 'test.tmpl');

$template->param(NUMBER => $number);
$template->param(NAME => $name);
$template->param(DAY => $day);

# Appropriate headers go here

print $template->output;

----------

<html>

<head>
<title>Today is <TMPL_VAR NAME=DAY>!</title>
</head>

<body>

<h1>Hello <TMPL_VAR NAME=NAME>, how are are you today?</h1>
<p>This is a random number generator: <TMPL_VAR NAME=NUMBER></p>

</body>

</html>

-----------
 
N

Nikos

Scott said:
<code snipped>

Thnk you very much Scott but unfortunately somethings still look strange
to me. :-(

Iam still confused but thanks for trying to help me. Maybe i should give
up the HTML::Template stuff and return back to cgi.pm or learn css or
maybe just give up on web page design once for all.
 
S

Scott Bryce

Nikos said:
Thnk you very much Scott but unfortunately somethings still look strange
to me. :-(

Iam still confused but thanks for trying to help me. Maybe i should give
up the HTML::Template stuff

Take this example, and read the docs. Try making tweaks to the example
and see what happens.
and return back to cgi.pm

Which serves a different purpose.
or learn css or

Which also serves a different purpose.
maybe just give up on web page design once for all.

Or find someone locally who can help until you understand it better?
 
F

Fabian Pilkowski

* Nikos said:
One is enouph thank you! :)

Please read carefully. They do *different* things, really. "Perl and
CGI.pm" is generating the output when someone requested your webpage via
browser. "Dreamweaver" could be used to generate HTML pages, but has
nothing to do with Perl (and I don't think, they could interact at all).
"Stylesheets" are used to separate layout and content inside a webpage.

Now, it's your part to choose what you want. After reading this thread
it seems like:

* use Dreamweaver to generate templates
* use Perl and HTML::Template to fill the templates with content
Can you please give the simplest example on html::template?

Gunnar has given a simple example on HTML::Template. Nevertheless I can
give you a rewrite of it, just to see how it works -- perhaps this gives
you the point you don't understand yet. Assume this in 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>

This is an example of template that HTML::Template needs to work. The
tags named <tmpl_var> are the variables which will be filled in by a
Perl sript later. It's your job to generate such templates, either by
type them by hand or by using Dreamweaver, you mentioned above. But this
newsgroup is not the right place to ask, how (or if?) Dreamweaver could
be used for this. However, after you have such an template, you can fill
it by using Perl.


#!/usr/bin/perl
use strict;
use warnings;

# You need CGI.pm, eg. to generate a valid header, perhaps you're
# doing some other stuff with it, like parsing parameters.
use CGI;
use CGI::Carp qw( fatalsToBrowser );

# You need HTML/Template.pm to process your template.
use HTML::Template;

# Declare the vars you want to put into your template, this could
# be easily done with a hash. In general, you get your values by
# calculating something, connecting to a database etc.
my %tmplvar = (
HEADER => 'My Template',
VAR1 => 'template',
VAR2 => 'templating system'
);

# Now, all needed vars are saved in the hash. It's time to read in
# the template file.
my $tmpl = HTML::Template->new( filename => 'mytemplate.html' );

# Fill in the template with your values, here we do this in one step
# by passing the whole hash to param(). Gunnar has shown how to set
# each var separately.
$tmpl->param( %tmplvar );

# The vars are determined, the template is filled with them -- let's
# write it out. First the header (as usual, you know?), followed by
# the template's output.
print CGI::header(), $tmpl->output;
__END__


If you ignore all my comments, it's not really a long perl script, isn't
it? But that's really all, you have to do (I know, I wrote it already):

* generating the template and
* fill in the template

Dreamweaver could help you to generate the templates (perhaps), and Perl
does help you to fill them with your content. The Perl modules »CGI« and
»HTML::Template« are just helping you with that. Sure, you could reject
this help and stick your own with an regex (Gunnar has done this in his
first code snippet), but I don't recommend that.

Last but not least, your templates could contains style sheets (CSS).
That's the usual way to reduce formatting directives in HTML (doesn't
matter if it is an template or not).

Hope this helps.

regards,
fabian
 
N

Nikos

Fabian Pilkowski wrote:

[snip explained code]

Thanks a lot Fabian now its more clear to me but i still cant convert
this index.pl script i made with the use of cgi.pm to the HTML::Template
way. Here is is btw:

#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
use CGI qw:)standard);
use DBI;
use DBD::mysql;

@months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
'Sep', 'Oct', 'Nov', 'Dec');
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime;
$xronos = "$mday $months[$mon], $hour:$min";

$ip = $ENV{'REMOTE_ADDR'};
@numbers = split (/\./,$ip);
$address = pack ("C4", @numbers);
$host = gethostbyaddr ($address, 2) || $ip;
$host = "ÁÖÅÍÔÉÊÏ" if ( ($host eq "localhost") or ($host eq
"dslcustomer-221-228.vivodi.gr" or $host eq "dell") );

print header( -charset=>'iso-8859-7' );
print start_html( -style=>'../style.css', -title=>'Øõ÷ùöåëÞ ÐíåõìáôéêÜ
Êåßìåíá!' );


$db = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net')
? DBI->connect('DBI:mysql:nikos_db', 'root', '')
: DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', 'tiabhp2r')
or print font({-size=>5, -color=>'Lime'}, $DBI::errstr) and exit 0;

#*******************************************************************************
@files = <../data/text/*.txt>;
@display_files = map( /([^\/]+)\.txt/, @files );

print start_form(-action=>'index.pl');
print p( {-align=>'center'}, font( {-size=>5, -color=>'Lime'},
'Ëüãïò Øõ÷ùöåëÞò êáé ÈáõìÜóéïò => ' ),
popup_menu( -name=>'select',
-values=>\@display_files ),
submit('ok'));
print end_form(), br();

$keimeno = param('select') or "Áñ÷éêÞ Óåëßäá";

$st = $db->prepare( "SELECT host FROM logs" );
$st->execute();
while( $row = $st->fetchrow_hashref ) {
if( $host eq $row->{host} ) {
$hostmatch = 1;
}
}

if( param('select') and param('select') !~ /\.\./ )
{
open(FH, "<../data/text/$keimeno.txt") or die $!;
@data = <FH>;
close(FH);

$data = join('', @data);

$db->do( "UPDATE logs SET keimeno='$keimeno' WHERE host='$host'" )
or die $db->errstr;
}
elsif( $hostmatch == 1 )
{
$db->do( "UPDATE logs SET visits = visits + 1 WHERE host='$host'" )
or die $db->errstr;
$st = $db->prepare( "SELECT * FROM logs WHERE host='$host'" );
$st->execute();
$row = $st->fetchrow_hashref;

$data = "Êáëþò Þñèåò " .$host. "! ×áßñïìáé ðïëý ðïõ óå îáíáâëÝðù!\n" .
"Ôåëåõôáßá öïñá Þñèåò åäþ ùò " .$row->{host}. " óôéò "
..$row->{xronos}. " !!\n" .
"ÁõôÞ åßíáé ç " .$row->{visits}. " öïñÜ ðïõ åðéóêÝöôåóáé ôçí
óåëßäá ìïõ êáé ÷áßñïìáé ðïëý ðïõ ôçí âñßóêåéò åíäéáöÝñïõóá !!!\n" .
"Ôçí ôåëåõôáßá öïñÜ äéÜâáóåò ôï êåßìåíï [ "
..$row->{keimeno}. " ]\n" .
"Ðïéo ëüãï èá Þèåëåò íá ìåëåôÞóåéò áõôÞí ôç öïñÜ ?!?";
}
elsif( $hostmatch != 1 )
{
if ( $host ne "ÁÖÅÍÔÉÊÏ" )
{
$data = "Êáëþò üñéóåò " .$host. "!\n" .
"ÁõôÞ åéíáé ç 1ç óïõ åðßóêåøç åäþ ðÝñá! Åëðßæù íá óïõ
áñÝóåé!\n" .
"Áíïßãïíôáò ôï ðáñáðÜíù drop-down menu åðÝëåîå ôï êåßìåíï
ðïõ èá Þèåëåò íá äéáâÜóåéò...";

$db->do( "INSERT INTO logs VALUES (null, '$host', '$xronos',
'$text', 1)" ) or die $db->errstr;
}
else
{
$data = "Ôé ÷áìðÜñéá $host :) ÈõìÞèçêåò íá ìå ðåñéðïéçèåßò êáé
åìÝíá ëéãÜêé !?!";
}
}

$data =~ s/\n/\\n/g;
$data =~ s/"/\\"/g;
$data =~ tr/\cM//d;

#*******************************************************************************
print <<ENDOFHTML;
<html><head><title></title>
<script type='text/javascript'>

var textToShow = "$data";
var tm;
var pos = 0;
var counter = 0;

function init()
{ tm = setInterval("type()", 45) }

function type()
{
if (textToShow.length != pos)
{
d = document.getElementById("DivText");
c = textToShow.charAt(pos++);

if (c.charCodeAt(0) != 10)
d.appendChild(document.createTextNode(c));
else
d.appendChild(document.createElement("br"));

counter++;

if (counter >= 1800 && (c.charCodeAt(0) == 10 || c == "."))
{
d.appendChild(document.createElement("br"));
d.appendChild(document.createTextNode("Press any key..."));
counter = 0;
clearInterval(tm);
document.body.onkeypress = function () {
document.getElementById("DivText").innerHTML = '';
tm =
setInterval("type()", 50);

document.body.onkeypress = null; };
}
}
else
clearInterval(tm);
}
</script>

<body onload=init()>
<center>
<div id="DivText" align="Left" style="
background-image: url(../data/images/kenzo.jpg);
border: Ridge Orange 5px;
width: 850px;
height: 500px;
color: LightSkyBlue;
font-family: Times;
font-size: 18px;">
</div
ENDOFHTML
#*******************************************************************************

print br(), br(), br();
print start_form(-action=>'show.pl');
print table(
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();

open(FH, "<../data/text/tips") or die $!;
@tips = <FH>;
close(FH);

@tips = grep { !/^\s*\z/s } @tips;
$tip = $tips[int(rand(@tips))];

print table(
Tr( td( {class=>'tip'}, $tip ))
);

$db->do( "UPDATE counter SET counter = counter + 1" ) if ($host ne
"ÁÖÅÍÔÉÊÏ");

$st = $db->prepare( "SELECT counter FROM counter" );
$st->execute();
$row = $st->fetchrow_hashref;

print br();
print table(
Tr( td( {class=>'host'}, $host )),
Tr( td( {class=>'xronos'}, $xronos )),
Tr( td( {class=>'counter'}, $row->{counter} ))
);

print a( {href=>'games.pl'},
img{src=>'../data/images/games.gif'} );
print p( {-align=>'right'}, a( {href=>'show.pl?onoma=showlog'}, font(
{-size=>2, -color=>'Lime'}, b( 'Last Update: 18/4/2005' ))));


What i am trying to figure out is if the above script would be more
straightforward with the use of HTML::Template.
I tried to do ti but i didnt managed it....as expected.

The idea is to Separate the html from the pure perl code(here we dont
have html really since i use cgi.pm) but by trying that i *must* write
from scratch the pure html code(which i am trying to avoid) of the
script and the pure perl code which of course this time would be much
smaller. But i also have Javascript inserted here....

Do you really think that the above script can be rewritten in a more
straightforward way considering the use of the methods we discussed?

If yes, can you guys help me convert it so to see if it fits me better...
I tried a little according to the directives you provided, but because i
made a lot of errors i stopped before i hit the keyboard and screen.
 
N

Nikos

Scott said:
Which serves a different purpose.

But with cgi.pm i can print all the variables i want, its just that perl
code and html(cgi.pm's functions) is in the same file.
Or find someone locally who can help until you understand it better?

Nobody i know, knows Perl :>
 
S

Scott Bryce

Nikos said:
What i am trying to figure out is if the above script would be more
straightforward with the use of HTML::Template.

Probably, but I doubt anyone is going to go through all of that code to
show you how.
The idea is to Separate the html from the pure perl code(here we dont
have html really since i use cgi.pm)

The end result is still HTML.
but by trying that i *must* write
from scratch the pure html code(which i am trying to avoid)

In order to use ANY templating system, you will have to have an HTML
file in which to drop the desired values. There is no way around that.
You keep mentioning DreamWeaver. You could write the HTML in
Dreamweaver, then tweak the HTML to make a template from it.
Do you really think that the above script can be rewritten in a more
straightforward way considering the use of the methods we discussed?

You will have to decide whether you want to use CGI.pm to do HTML
output, or use a templating system.
 
F

Fabian Pilkowski

* Nikos said:
Fabian Pilkowski wrote:

Thanks a lot Fabian now its more clear to me but i still cant convert
this index.pl script i made with the use of cgi.pm to the HTML::Template
way. Here is is btw:

#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use CGI::Cookie;
use CGI qw:)standard);
use DBI;
use DBD::mysql;

Please, don't forget to use

use strict;
use warnings;

these days. If you don't know what this will do, read the identically
named sections in perldoc.

[...]
$data = "Êáëþò Þñèåò " .$host. "! ×áßñïìáé ðïëý ðïõ óå îáíáâëÝðù!\n" .
"Ôåëåõôáßá öïñá Þñèåò åäþ ùò " .$row->{host}. " óôéò "
.$row->{xronos}. " !!\n" .
"ÁõôÞ åßíáé ç " .$row->{visits}. " öïñÜ ðïõ åðéóêÝöôåóáé ôçí
óåëßäá ìïõ êáé ÷áßñïìáé ðïëý ðïõ ôçí âñßóêåéò åíäéáöÝñïõóá !!!\n" .
"Ôçí ôåëåõôáßá öïñÜ äéÜâáóåò ôï êåßìåíï [ "
.$row->{keimeno}. " ]\n" .
"Ðïéo ëüãï èá Þèåëåò íá ìåëåôÞóåéò áõôÞí ôç öïñÜ ?!?";

Ehm, could *you* read this? I assume this are many of Greek letters,
since your headers show me, you're from Greece. But nevertheless, your
header declare "iso-8859-1" as charset which doesn't contain any Greek
letter. So, why using Greek chars in your posting? Or even better: Why
not choosing a charset like "iso-8859-7" where all of your chars exist?
What i am trying to figure out is if the above script would be more
straightforward with the use of HTML::Template.
I tried to do ti but i didnt managed it....as expected.

The idea is to Separate the html from the pure perl code(here we dont
have html really since i use cgi.pm) but by trying that i *must* write
from scratch the pure html code(which i am trying to avoid) of the
script and the pure perl code which of course this time would be much
smaller. But i also have Javascript inserted here....

It's no problem if your template contains JavaScript code.
Do you really think that the above script can be rewritten in a more
straightforward way considering the use of the methods we discussed?

You can get all your HTML code by reqesting it from your script you have
shown above. Then read through it and replace each potentially variable
with its corresponding HTML-Template-tag »<tmpl_var ...>«. This way, you
get a template based on your previous script.

Afterwards, you just have to fill in these values. This could be done
the same way as in your old script -- just with one difference: don't
print these values out with CGI.pm's methods rather than store them in
one hash, as I mentioned in my previous posting.

Finally, you have to reading the template, filling in your values and
printing it out -- nothing you don't know about.
If yes, can you guys help me convert it so to see if it fits me better...
I tried a little according to the directives you provided, but because i
made a lot of errors i stopped before i hit the keyboard and screen.

Sounds, you generate your templates by hand, not by Dreamweaver. For me,
that's the usual (and sometimes fastest) way to do this ;-)

I'll hope, the explanation above could help you.

regards,
fabian
 
J

johnh

Not much help to the original poster, but I just wanted to say that
there is one way in which Perl and Dreamweaver can "work together" --
it's possible to add new tags, for instance, the HTML::Template tags,
to Dreamweaver, at which point they will be pretty-printed, checked,
auto-completed etc just like all other tags.

In my version it's done via "Tag Libraries..." at the bottom of the
Edit menu, but things tend to move around in different versions of DW.
You not only add the tag but the correct attributes as well. Say what
you like about DW but it's not short of features.
 
N

Nikos

Fabian said:
Ehm, could *you* read this? I assume this are many of Greek letters,
since your headers show me, you're from Greece. But nevertheless, your
header declare "iso-8859-1" as charset which doesn't contain any Greek
letter. So, why using Greek chars in your posting? Or even better: Why
not choosing a charset like "iso-8859-7" where all of your chars exist?

But i only have one header and that with thew Greek iso char support!
print header( -charset=>'iso-8859-7' );

Anyways if i understand you correctly i run the script in firefox and
saw what html code it produced by selecting "view code".

Man, this hmtl code is very messy. Here is is btw:
Content-Type: text/html; charset=iso-8859-7
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"><head><title>Øõ÷ùöåëÞ ÐíåõìáôéêÜ Êåßìåíá!</title>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head><body><form method="post" action="index.pl"
enctype="application/x-www-form-urlencoded">
<p align="center"><font color="Lime" size="5">Ëüãïò Øõ÷ùöåëÞò êáé
ÈáõìÜóéïò => </font> <select name="select">
<option value="¸íá ìÞíõìá óå üëïõò ôïõò Üðéóôïõò">¸íá ìÞíõìá óå üëïõò
ôïõò Üðéóôïõò</option>
<option value="Áãéïò ÉùÜííçò ï Äáìáóêçíüò -- Ðåñß Ðáèþí">Áãéïò ÉùÜííçò ï
Äáìáóêçíüò -- Ðåñß Ðáèþí</option>
<option value="Áãéïò Íåßëïò ï ÁóêçôÞò -- Ðåñß Áíôé÷ñßóôïõ">Áãéïò Íåßëïò
ï ÁóêçôÞò -- Ðåñß Áíôé÷ñßóôïõ</option>
<option value="ÅõöõïëïãÞìáôá -- ÊÜðïéïé ÊÜðïõ ÊÜðïôå">ÅõöõïëïãÞìáôá --
ÊÜðïéïé ÊÜðïõ ÊÜðïôå</option>
<option value="Åöñáßì Êáôïõíáêéþôçò -- Ðåñß Åõ÷Þò">Åöñáßì Êáôïõíáêéþôçò
-- Ðåñß Åõ÷Þò</option>
<option value="Ç Èñçóêåßá óôï ÄùäåêÜèåï">Ç Èñçóêåßá óôï ÄùäåêÜèåï</option>
<option value="Ç áëÞèåéá ãéá ôéò øõ÷Ýò ôùí êåêïéìçìÝíùí">Ç áëÞèåéá ãéá
ôéò øõ÷Ýò ôùí êåêïéìçìÝíùí</option>
<option value="ÈáíÜóéìá áìáñôÞìáôá">ÈáíÜóéìá áìáñôÞìáôá</option>
<option value="Èåüêëçôïò ÄéïíõóéÜôçò -- Ðåñß Äáéìüíùí">Èåüêëçôïò
ÄéïíõóéÜôçò -- Ðåñß Äáéìüíùí</option>
<option value="ÉùóÞö Çóõ÷áóôÞò -- Ðåñß Åõ÷Þò Íï1">ÉùóÞö Çóõ÷áóôÞò --
Ðåñß Åõ÷Þò Íï1</option>
<option value="ÉùóÞö Çóõ÷áóôÞò -- Ðåñß Åõ÷Þò Íï2">ÉùóÞö Çóõ÷áóôÞò --
Ðåñß Åõ÷Þò Íï2</option>
<option value="Ëáôñåõôéêü Åã÷åéñßäéï -- Ðåñß Åõ÷Þò">Ëáôñåõôéêü
Åã÷åéñßäéï -- Ðåñß Åõ÷Þò</option>
<option value="Ëáôñåõôéêü Åã÷åéñßäéï -- Ðåñß Óêáíäáëéóìïý">Ëáôñåõôéêü
Åã÷åéñßäéï -- Ðåñß Óêáíäáëéóìïý</option>
<option value="Ìåôåìøý÷ùóç">Ìåôåìøý÷ùóç</option>
<option value="Ïé ðÜðõñïé ôçò ÍåêñÜò ÈÜëáóóáò">Ïé ðÜðõñïé ôçò ÍåêñÜò
ÈÜëáóóáò</option>
<option value="Ðßóôåõå êáé ìç åñåýíá">Ðßóôåõå êáé ìç åñåýíá</option>
<option value="ÐåñéðÝôåéò åíüò ÐñïóêõíçôÞ -- Ðåñß Ðñïóåõ÷Þò">ÐåñéðÝôåéò
åíüò ÐñïóêõíçôÞ -- Ðåñß Ðñïóåõ÷Þò</option>
<option value="Ðïý ðÜìå ìåôÜ èÜíáôï;">Ðïý ðÜìå ìåôÜ èÜíáôï;</option>
<option value="Ðñüóå÷å ôçí øõ÷Þ óïõ">Ðñüóå÷å ôçí øõ÷Þ óïõ</option>
<option value="Ó÷Ýóç ×ñéóôéáíïý ìå êïóìéêüôçôá">Ó÷Ýóç ×ñéóôéáíïý ìå
êïóìéêüôçôá</option>
</select> <input type="submit" name="ok" value="ok"
/></p><div></div></form><br /><html><head><title></title>
<script type='text/javascript'>
var textToShow = "Ôé ÷áìðÜñéá ÁÖÅÍÔÉÊÏ :) ÈõìÞèçêåò íá ìå ðåñéðïéçèåßò
êáé åìÝíá ëéãÜêé !?!";
var tm;
var pos = 0;
var counter = 0;
function init()
{ tm = setInterval("type()", 45) }
function type()
{
if (textToShow.length != pos)
{
d = document.getElementById("DivText");
c = textToShow.charAt(pos++);
if (c.charCodeAt(0) != 10)
d.appendChild(document.createTextNode(c));
else
d.appendChild(document.createElement("br"));
counter++;
if (counter >= 1800 && (c.charCodeAt(0) == 10 || c == "."))
{
d.appendChild(document.createElement("br"));
d.appendChild(document.createTextNode("Press any key..."));
counter = 0;
clearInterval(tm);
document.body.onkeypress = function () {
document.getElementById("DivText").innerHTML = '';
tm =
setInterval("type()", 50);

document.body.onkeypress = null; };
}
}
else
clearInterval(tm);
}
</script>
<body onload=init()>
<center>
<div id="DivText" align="Left" style="
background-image: url(../data/images/kenzo.jpg);
border: Ridge Orange 5px;
width: 850px;
height: 500px;
color: LightSkyBlue;
font-family: Times;
font-size: 18px;">
</div
<br /><br /><br /><form method="post" action="show.pl"
enctype="application/x-www-form-urlencoded">
<table><tr align="center"><td>Ðþò óå ëÝíå áäåëöÝ?</td> <td><input
type="text" name="onoma" /></td></tr> <tr align="center"><td>ÐïéÜ åßíáé
ç ãíþìç óïõ ãéá ôçí åõ÷ïýëá
"Êýñéå Éçóïý ×ñéóôÝ ÅëÝçóïí
Ìå"?</td> <td><textarea name="euxoula" rows="4"
cols="25"></textarea></td></tr> <tr align="center"><td>ÌïéñÜóïõ ìáæß ìáò
ìßá êáôÜ ôç ãíþìç óïõ
èáõìáóôÞ ðñïóùðéêÞ ðíåõìáôéêÞ åìðåéñßá
áðü êÜðïéïí ãÝñïíôá ðñïò þöåëïò ôùí
õðïëïßðùí áäåëöþí (áí öõóéêÜ Ý÷åéò
:)</td> <td><textarea name="sxolio" rows="6"
cols="25"></textarea></td></tr> <tr align="center"><td>Ðïéü åßíáé ôï
e-mail óïõ?</td> <td><input type="text" name="email"
value="(e-mail address removed)" /></td></tr> <tr align="center"><td><input
type="submit" name="ÅìöÜíéóç üëùí ôùí áðüøåùí" value="ÅìöÜíéóç üëùí ôùí
áðüøåùí" /></td> <td><input type="submit" name="ÁðïóôïëÞ"
value="ÁðïóôïëÞ" /></td></tr></table><div></div></form><br /><br
/><table><tr><td class="tip"># ÌÇÍ ÓÔÅÍÁ×ÙÑÉÅÓÅ ÃÉÁ ÐÑÁÃÌÁÔÁ ÐÏÕ
ÄÉÏÑÈÙÍÏÍÔÁÉ ÊÁÉ ÃÉÁ ÐÑÁÃÌÁÔÁ ÐÏÕ ÄÅÍ ÄÉÏÑÈÙÍÏÍÔÁÉ
</td></tr></table><br /><table><tr><td class="host">ÁÖÅÍÔÉÊÏ</td></tr>
<tr><td class="xronos">20 Apr, 11:26</td></tr> <tr><td
class="counter">1110</td></tr></table><a href="games.pl"><img
src="../data/images/games.gif" /></a><p align="right"><a
href="show.pl?onoma=showlog"><font color="Lime" size="2"><b>Last Update:
18/4/2005</b></font></a></p>

How am i going to put it together correctly and what about the option
values? in the drop down menu?
I see the html code and i am scared of touching it...its too messy.
 
F

Fabian Pilkowski

* Nikos said:
But i only have one header and that with thew Greek iso char support!
print header( -charset=>'iso-8859-7' );

Err, I meant the header of your posting here, not the header generated
by your script ;-)
Anyways if i understand you correctly i run the script in firefox and
saw what html code it produced by selecting "view code".

Man, this hmtl code is very messy. Here is is btw:

I see, it's hard to do anything with that HTML code produced by CGI.pm.
But, and that could help you a lot, there's a module named CGI::pretty,
a subclass of CGI.pm. Try to replace »use CGI« with »use CGI::pretty«
and look at your HTML code afterwards. It might be a bit smoother.

regards,
fabian
 
N

Nikos

Fabian said:
Err, I meant the header of your posting here, not the header generated
by your script ;-)

You mean that i shouls set my newsclient reader to send posts away with
the Greek char set instead of the english one?

But what if my post has Greek and English inside it? :)

I see, it's hard to do anything with that HTML code produced by CGI.pm.
But, and that could help you a lot, there's a module named CGI::pretty,
a subclass of CGI.pm. Try to replace »use CGI« with »use CGI::pretty«
and look at your HTML code afterwards. It might be a bit smoother.

Thanks ill try it to do it right away.
I think thought that it would be more easier to donwload Dreamweaver MX
and create the webpage from scratch and then use the templatin system
HTML::Template to insert values in the right places of the Dreamweaver's
html output?

What do you think? Byhand or by Dreamweaver?
Also with DW i would be able to create more fancy stuff that i could do
with handcoded html.


Also in my the html output i have this:

<option value="ёнб мЮнхмб уе ьлпхт фпхт Ьрйуфпхт">ёнб мЮнхмб уе ьлпхт
фпхт Ьрйуфпхт</option>
<option value="Бгйпт ЙщЬннзт п Дбмбукзньт -- РеÑЯ Рбиюн">Бгйпт ЙщЬннзт п
Дбмбукзньт -- РеÑЯ Рбиюн</option>
<option value="Бгйпт ÐеЯлпт п БукзфЮт -- РеÑЯ БнфйчÑЯуфпх">Бгйпт ÐеЯлпт
п БукзфЮт -- РеÑЯ БнфйчÑЯуфпх</option>
<option value="ЕхцхплпгЮмбфб -- КЬрпйпй КЬрпх КЬрпфе">ЕхцхплпгЮмбфб --
КЬрпйпй КЬрпх КЬрпфе</option>

Dont bother about the Greek. I copy pasted from the editor here but i
dont know why it looks so funny.

The above html output is produced by this perl code:

print p( {-align=>'center'}, font( {-size=>5, -color=>'Lime'},
'Ëüãïò Øõ÷ùöåëÞò êáé ÈáõìÜóéïò => ' ),
popup_menu( -name=>'select', -values=>\@display_files ),
submit('ok'));

If i try to replace the values in the html with tmpl_var name=something
what must i insert and how?

one by one? What if the selections on the dropdown menu its 100+?

i must insert code one by one? Whatis the way?
 
F

Fabian Pilkowski

* Nikos said:
You mean that i shouls set my newsclient reader to send posts away with
the Greek char set instead of the english one?

Just if it contains such Greek data inside.
But what if my post has Greek and English inside it? :)

That's no problem since all english chars are in each iso-8859-x charset
(the first 128 chars) and only the ones from 129 upwards will differ.
But now, your posting is encoded in utf-8, so there's no trouble with
your Greek characters ;-)
Thanks ill try it to do it right away.
I think thought that it would be more easier to donwload Dreamweaver MX
and create the webpage from scratch and then use the templatin system
HTML::Template to insert values in the right places of the Dreamweaver's
html output?

What do you think? Byhand or by Dreamweaver?
Also with DW i would be able to create more fancy stuff that i could do
with handcoded html.

Have you read the posting from "johnh" in this thread. He's pointing out
that you can use Dreamweaver to generate your templates and its special
tags. Therefore, I would try that way -- since you're using Dreamweaver
already.

Whether to create your templates from scratch or by changing your old
pages generated by CGI.pm -- I couldn't help you to decide. It's your
part to check out which one is the right for you.
Also in my the html output i have this:

<option value="ёнб мЮнхмб уе ьлпхт фпхт Ьрйуфпхт">ёнб мЮнхмб уе ьлпхт
фпхт Ьрйуфпхт</option>
<option value="Бгйпт ЙщЬннзт п Дбмбукзньт -- РеÑЯ Рбиюн">Бгйпт ЙщЬннзт п
Дбмбукзньт -- РеÑЯ Рбиюн</option>

Dont bother about the Greek. I copy pasted from the editor here but i
dont know why it looks so funny.

Yes, your posting is encoded correctly, so I can see the Greek ;-)
The above html output is produced by this perl code:

print p( {-align=>'center'}, font( {-size=>5, -color=>'Lime'},
'Ëüãïò Øõ÷ùöåëÞò êáé ÈáõìÜóéïò => ' ),
popup_menu( -name=>'select', -values=>\@display_files ),
submit('ok'));

If i try to replace the values in the html with tmpl_var name=something
what must i insert and how?

Please consider to have a closer look to the docs shipped with the
module. There exists a template tag <tmpl_loop> which is exactly what
you need for such things. Therewith, you have to pass an arrayref to the
param() method to fill in your template.

regards,
fabian
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top