|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
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]And here's the script code: [code] Please help me  ! Thanks (y)
|
|
|
|
Joined: Sep 2001
Posts: 379
Member
|
Member
Joined: Sep 2001
Posts: 379 |
Seems like someone was a little bit tired when he wrote the wordlets_template. [/code]Replace it with:
</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] 
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
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 
"Annnnnnnndd now, opening for Iron Maiden...... WYLD STALLYNS!!!" --Bill S. Preston, Esquire and Ted "Theodore " Logan
|
|
|
|
Joined: Sep 2001
Posts: 379
Member
|
Member
Joined: Sep 2001
Posts: 379 |
True, just didn't want to make it too complicated. 
|
|
|
|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
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 
|
|
|
|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
Joined: Jun 2002
Posts: 7 |
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?
|
|
|
|
Joined: Sep 2001
Posts: 379
Member
|
Member
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. Edit: HTML::Template
|
|
|
|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
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 
|
|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
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.
|
|
|
|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
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 ALso, thanks for the replies guys 
|
|
|
|
Joined: Aug 2000
Posts: 335
Member
|
Member
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.
|
|
|
|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
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
|
|
|
|
Joined: Sep 2000
Posts: 755
P.I.T.A. / Programmer
|
P.I.T.A. / Programmer
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
|
|
|
|
Joined: Jun 2002
Posts: 7
Junior Member
|
Junior Member
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 
|
|
|
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.
|
|
Posts: 1,157
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|