Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Is this code in Perl or CGI?

by perl2010 (Initiate)
on Jan 12, 2010 at 16:39 UTC ( #816985=perlquestion: print w/replies, xml ) Need Help??
perl2010 has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl require ''; &form_handler; $textdir = "../../data/text"; $docfile = "../../htdocs/cowboys/$FORM{'3'}"; for ($count = 1; $count < 5; $count++) { if ($FORM{'$count'} =~ /\//g || $FORM{'$count'} =~ /\.\./) { error(); +exit; } } use POSIX; $date = strftime("%H:%M %m/%d/%Y",localtime); open (OLDCHAT, "$textdir/$FORM{'1'}") || die "text file doesn't exist" +; @old = <OLDCHAT>; ##get copy of old comments open (ADDCHAT, ">$textdir/$FORM{'1'}"); #empty old comments $FORM{'name'} =~ s/\<+.+\>*//g; $FORM{'location'} =~ s/\<+.+\>*//g; $FORM{'comments'} =~ s/\<+.+\>*//g; $FORM{'comments'} =~ s/\n+//g; open (BAD, "$textdir/bad.txt") || die "can't open bad"; @bad=<BAD>; foreach $bad(@bad) { chop ($bad); if ($FORM{'comments'} =~ /$bad/ig) { $FORM{'comments'} =~ s/$b +ad/\%\$\#\&\!\%/gi; next;} } print ADDCHAT ("<H4>$FORM{'name'} from $FORM{'location'} said:</h4> $F +ORM{'comments'} <BR> <H6>$date</H6><P> <!--$ENV{REMOTE_HOST}--><HR>\n +"); #print new comment on top for (@old) { s/\s+/ /g; s/\n+//g; s/<HR>/<HR>\n/g; } if (scalar @old>200) { pop(@old) until scalar @old < 200; } print ADDCHAT @old; #add old comments close ADDCHAT; open (TOP, "$textdir/$FORM{'2'}"); @top = <TOP>; open (CHAT, "$textdir/$FORM{'1'}"); @new = <CHAT>;#get copy of updated comments open (NEWCHAT, ">$docfile") or &debug($FORM{'3'}); select(NEWCHAT); &html_header("$FORM{'4'}"); print "@top"; print "@new"; &html_footer; close NEWCHAT; select(STDOUT); print "Location:$FORM{'3'}\n\n"; exit(0); sub error { print "Content-type: text/html\n\n"; &html_header("Error"); print<<"GOOF"; A system error occrred. Perhaps you tried to use an illegal character. GOOF &html_footer; 0; } sub debug { my $debugpage = shift(@_); print "Content-type: text/html\n\n"; &html_header("Error"); print<<"GOOF"; Could not open $debugpage for writing! GOOF &html_footer; 0; }

Replies are listed 'Best First'.
Re: Is this code in Perl or CGI?
by almut (Canon) on Jan 12, 2010 at 16:46 UTC

    Seems to be a CGI script written in Perl :)

Re: Is this code in Perl or CGI?
by marto (Archbishop) on Jan 12, 2010 at 16:47 UTC

    Please read and understand How do I post a question effectively?, you've posted code, but no question or error message.

    Update: Ah, the question was in the subject line, my mistake. This is a CGI script written in Perl, but not using the CGI perl module.

Re: Is this code in Perl or CGI?
by RyuMaou (Deacon) on Jan 12, 2010 at 16:52 UTC
    This seems like a trick question...
    This is Perl, for sure, but, it's a CGI script that outputs something in HTML. Or, at least the error messages are HTML. You can tell it's Perl from the opening line:


    Based on the variables, it looks like some kind of chat client, but, without the "" script, it's kind of hard to tell exactly what this does, or is meant to do.

    Hope that helps!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://816985]
Approved by Corion
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-06-24 20:50 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.