Previous Thread
Next Thread
Print Thread
Rate Thread
#103792 06/27/2002 7:12 AM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
Hi, since I read a lot about Perl right now, I thoight, giive it a try.. After not too long work,
I kinda made it to the end of this guestbook.. It must show a template, but instead it gives a nasty error:

Code
[/code]And here's the script code: 
[code]
Please help me help ! Thanks (y)

Sponsored Links
#103793 06/27/2002 8:43 AM
Joined: Sep 2001
Posts: 379
Member
Member
Offline
Joined: Sep 2001
Posts: 379
Seems like someone was a little bit tired when he wrote the wordlets_template. wink

Code
[/code]Replace it with:
Code
</pre></div></div>Also, in my opinion it is better to use fewer prints and instead, make an variable for all the HTML stuff, then print that variable.<br><br>For example:<br><br>[code]
smile

#103794 06/27/2002 9:38 AM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
Actually, it's far better to move the HTML into a seperate file entirely. Preferably use something like HTML::Template.

Personal pet peeve of mind. I can't stand having HTML mixed in with my code. Seperation of logic and display goooooood smile


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#103795 06/27/2002 10:35 AM
Joined: Sep 2001
Posts: 379
Member
Member
Offline
Joined: Sep 2001
Posts: 379
True, just didn't want to make it too complicated. laugh

#103796 06/27/2002 12:07 PM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
Mark, how do I get the HTML::Template file using as a module? Do I need to use package, or import($module). Please help me, I'm going to change the error fixes now.. Oh yea, I Guess I was a bit tired, scipting at 22.30 until, le's say 12.00 with a few beers wink

Sponsored Links
#103797 06/27/2002 12:27 PM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
frown
It still gives the nasty error.. I know there ae some bugs and the script is not perfectionized, but ithas to be in the subs.. I only call a template and some default arguments.. help please?

#103798 06/27/2002 4:21 PM
Joined: Sep 2001
Posts: 379
Member
Member
Offline
Joined: Sep 2001
Posts: 379
Alright, I had a better look at the code, and I must say it's rather confusing, sorry. :rolleyes:

Anyway, I have no idea why you're trying to use read(), when open is probably what you really want to do.
The read function was designed to be the equivalent of the UNIX fread command,
which enables you to read arbitrary number of bytes into a scalar variable.
The syntax is something like: read (filevar, result, length, skipval);
Where "skipval" is optional.
Not going into any more details on that function here.

I got rid of the errors for you,
you can see the file by clicking this link .
Hope that helps a little bit. wink

Edit: HTML::Template

#103799 06/28/2002 11:39 AM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
Thanks Idle, the Gueestbook does popups with no kinds of errors, but I am not able to post a message. check out:

http://gotanscgi.netfirms.com/gb_code.txt
for the script code.. I made 2 files now,
and check out http://gotanscgi.netfirms.com/guestbook_edited.cgi
for the guestbook..
I am getting nothing when I am trying to post a message! Help me please! This is my first scripts, and I want my Perl to be very good, even if I tried to learning it just over a month ago wink

#103800 06/28/2002 2:41 PM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
Re: HTML::Template

I used this for a script I wrote, and later regretted it.

1) There was a report that HTML::Template has memory leaks. This might not be a big problem for a CGI script, but could be serious if you're using mod_perl. I've have some more info on this if you're interested, although not enough information to fix the problem. But that was several months ago. Maybe the problem has been fixed.

2) Doing complex stuff like dynamic nested tables was tricky. As I recall, a two-level nested table requires setting up an array of hashes of arrays of hashes.

I agree that separating the HTML from the "guts" of the script is good methodology. I'm just not sure that HTML::Template is the best approach.

#103801 06/28/2002 3:09 PM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
Maybe I should use a package for the HTML Template instead using the module? Also, Dave, do you have seen a little rror, because the guestbook works properly, only it doesn't write the data to the file. Please help wink

ALso, thanks for the replies guys smile

Sponsored Links
#103802 06/30/2002 12:51 PM
Joined: Aug 2000
Posts: 335
Member
Member
Offline
Joined: Aug 2000
Posts: 335
I don't recall having any actual problems with HTML::Template myself.

The guy who reported the memory leak (which might be due a bug in Perl, rather than HTML::Template) wrote another template solution, Text::FastTemplate.

#103803 07/01/2002 3:14 AM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
Thanks Dave_L for this info. I think I will use this module in the near future, but later on, when I am a bit more experienced with it. Tomorrow I'm getting a huge Perl book, so that may come to any help. I am going to script now (Profile script).. bye

#103804 07/04/2002 5:54 PM
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
P.I.T.A. / Programmer
Offline
Joined: Sep 2000
Posts: 755
I've never run across any bugs with HTML::Template and I use it all the time. Could have just been something funky on the server.

I haven't used it much in conjuntion with mod_perl, but it's supposed to work well with it. Could have been an older version of the module too..

--mark


"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
#103805 07/07/2002 3:16 PM
Joined: Jun 2002
Posts: 7
Junior Member
Junior Member
Offline
Joined: Jun 2002
Posts: 7
My book explains the use of HTML::Template and how to use HTML::Template, in the near future, I think I will use this. However, for this simple Guestbook not, it us supposed to be very simple and all the extra files are not needed. I'm not sure to be using print($myhtml) (and concentate $myhtml each time, or printing << blocks.. I think << blocks, but i'm not sure if the printing takes longer or so smile


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)