Jump to content
xisto Community
Izlude

Perl/cgi Help! HTML skills required also.

Recommended Posts

Im sort of new with perl and I know the basics. Lemme paste the code ...

#!/usr/bin/perl -wif ($ENV{'REQUEST_METHOD'} eq 'POST') {   read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});   @pairs = split(/&/, $buffer);   foreach $pair (@pairs) {   ($name, $value) = split(/=/, $pair);   $value =~ tr/+/ /;   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])<br>/pack("C", hex($1))/eg;   $FORM{$name} = $value;   }  open (QUOTE, '>>logs.txt');  print QUOTE "<center>$FORM{quote}<br><br>\n\n";  print QUOTE "<hr width=20%></center><br><br>\n\n";  close (QUOTE);  &thx;}else {  &error;}

I have no problems with the subs .... I just want to end every line of text with a <br>. I have another perl script that reads the whole logs.txt file and pastes it into a HTML page. Can anyone help me?

Thanks in advance ...

Share this post


Link to post
Share on other sites

Just to let you know: I quit using Perl/CGI about 2 or 3 months ago and started learning PHP, but I still remember some of it, so I'll try my best to help you.

 

I think you called the item in the array wrong.

I usually did: $FORM[Name] instead of $FORM{Name}

That could be the problem you're having. Have you checked your error logs for the problem? By the way it looks, the rest is fine.

 

Here's what I think should be fixed:

$ENV{'REQUEST_METHOD'} to $ENV['REQUEST_METHOD']

$ENV{'CONTENT_LENGTH'} to $ENV['CONTENT_LENGTH']

$FORM{$name} = $value; to $FORM[$name] = $value;

$FORM{quote} to $FORM

 

I hope that helps you.

Share this post


Link to post
Share on other sites

First of all, I just checked all of my scripts, you had the correct format for an array, it is not necessarily $FORM['blah]. What do you mean by end with <br>. If you mean place the text "<br>" at the end of each line, simply place it in the end of each of your printed lines. That ought to work. If you tell us exactly what isn't working right we can provide better solutions.~Viz

Share this post


Link to post
Share on other sites

Thanks to you both for replying :D

Well .. I did a mass debug of the script and found that the problem I was looking for was not there lol.

open(READ,"<logs.txt") or die "Could not connect to database.";while (<READ>) { $s = $_; print "<br> $s";   };
the $s was being written to logs.txt in separate lines (as plain text), but since the other script (logs.pl) prints $s in a HTML page, it never line break'd.


Also ... the <br> inside this line messed up the first script posted above:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])<br>/pack("C", hex($1))/eg;

Thanks again. :o

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.