|
|
|
|
![]() ![]() |
Apr 10 2005, 10:59 PM
Post
#1
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 34 Joined: 3-April 05 From: Puerto Rico Member No.: 5,230 |
Im sort of new with perl and I know the basics. Lemme paste the code ...
CODE #!/usr/bin/perl -w if ($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 ... |
|
|
|
Apr 11 2005, 01:57 AM
Post
#2
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 372 Joined: 14-October 04 Member No.: 1,736 |
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[quote] I hope that helps you. |
|
|
|
Apr 13 2005, 10:44 PM
Post
#3
|
|
|
Member [Level 2] ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 79 Joined: 12-January 05 Member No.: 3,251 |
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 |
|
|
|
Apr 16 2005, 10:26 PM
Post
#4
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 34 Joined: 3-April 05 From: Puerto Rico Member No.: 5,230 |
Thanks to you both for replying
Well .. I did a mass debug of the script and found that the problem I was looking for was not there lol. CODE 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: CODE $value =~ s/%([a-fA-F0-9][a-fA-F0-9])<br>/pack("C", hex($1))/eg; Thanks again. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 27th July 2008 - 02:09 AM |