Izlude 0 Report post Posted April 10, 2005 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
Hamtaro 0 Report post Posted April 11, 2005 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
vizskywalker 0 Report post Posted April 13, 2005 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
Izlude 0 Report post Posted April 16, 2005 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. 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. Share this post Link to post Share on other sites