I'm writing this little page that lets you sort of have a conversation with a perl script, and i'm having a problem.

At the top of my php I access the perl script, with some text that the user input via a textbox. The perl responds with.. we'll say "Havin' a good one?<br>". This gets appended to $lasttext, and then that value is embeded in a hidden input form object that is named lasttext. So that when someone types some new info, and hits submit again. The text from the previous run is still available, and the new stuff just gets appended onto the end of it.

$example = exec('example.pl')
$lasttext.=$example
print "<form method=POST><input value=/"$lasttext/" type=hidden name=lasttext>"
print $lasttext;
print "<input type=submit></form>"

Now the first time I hit submit the output I would get would be

Havin' a good one?

The second time, i just want it to append the next set of text on the bottom, which works, but I get some side effects. My 2nd output would be

Havin\' a good one?
Me neither!

The third output would be

Havin\\\' a good one?
Me neither!
It's hot.

etc.... It just keeps adding the slashes. Anyone have a cleaner method to do this, or know of a way to fix this? I know this is more of a php oriented question, so my appoligies, I thought it might have something to do with regex which i know 0 about.

sorry for the syntax errors in that, Its syntactically working correctly, just not sure why it adds the slashes every time it posts

it's difficult to tell without the Perl script..... I personally would just use the PHP str_replace function and have it check for \'s in the text, and remove them..... I'm guessing it happens because of something in the perl script not getting cleared...or something about the page not getting reset... based on the information provided, that's the best I can come up with.

It could have something to do with a regexp, but since we can't see any regexps your code uses, there is no way to tell.

This article has been dead for over six months. Start a new discussion instead.