Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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 'utility2.pl'; &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: http://www.example.com/cowboys/$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; }

Comment on Is this code in Perl or CGI?
Download Code
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 (Chancellor) 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:

    "#!/usr/bin/perl"

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

    Hope that helps!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://816985]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-09-20 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls