Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Looking for feed back on a guestbook

by George_Sherston (Vicar)
on Nov 15, 2001 at 12:16 UTC ( [id://125525]=note: print w/replies, xml ) Need Help??


in reply to Looking for feed back on a guestbook

A few more pence in the pound:

(1) I'd use a module for stripping those tags, especially since you want to allow some and disallow others. I've not looked at this before, but there's bound to be one somewhere... searches CPAN for HTML stuff... well, just from glancing at the docs, looks like HTM::TagFilter would do just what you want. Looks as though it wd let you be pretty flexible abt what html you allowed your users, in an easy to maintain kind of way.

(2) Wog alluded to this one in a different context: you cd do your censor in one regex: $message =~ s/badword2|badword3|badword/bleep/ig;Although n.b. you have to be a little careful with the order of your search words, if some of them "contain" others. You notice I have
badword2|badword3|badword
instead of
badword|badword2|badword3
because the latter wd turn "badword2" into "bleep2".

(3) About printing out, I agree with the monks who say use CGI or die;, and also those who say that if you do
use CGI qw/:standard/;
You don't need then to do
my $q = new CGI; # and all the $q-> method calling
My preference in a short script (or in any script, because I have only a limited understanding of OO programming) is the former. Then you could do all your printing right at the end, after munging around your $message etc variables, with these lines which (and I agree beauty is in the eye of the beholder) I think are elegant and easy to read:
print header, start_html, p( {-align => center}, "Thanks for signing my guestbook, your message has been posted +! $name!", ), "Name: $name", br, "Email: $mail", br, "Message: $message", # ok, line above is a *bit* CGI-obsessive end_html;
Hope that's some use.

Please do post your revised code when you're finished with it, as it makes the thread a more complete learning resource for future generations.

§ George Sherston

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://125525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 16:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found