Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl formatting of text not working according to plan!

Status
Not open for further replies.

marybailey

Programmer
Mar 14, 2002
47
US
I want the text entered in my form to retain its original spacing and new lines. But its not!

Ok. Here goes ...

I have 2 textareas defined in an html form among other fields. They are defined as wrap=VIRTUAL tho wrap=hard and wrap= physical did not change the results.

I put the names and values of my form into an associative array.

My email textarea defined as follows in my html form:
<textarea name=&quot;emailsubject&quot; cols=&quot;40&quot; wrap=&quot;VIRTUAL&quot; rows=&quot;1&quot;></textarea><br>

My personalmsg textarea is defined as follows in my html form:
<textarea name=&quot;personalmsg&quot; cols=&quot;70&quot; wrap=&quot;virtual&quot; rows=&quot;10&quot;></textarea><br>


This is what I enter in the form:

for the emailsubject, I enter:
hi TESTING again

for the personalmsg, I enter:
hi
there.
testing
again.
* 1
* 2
* 3


When I print out the values of the emailsubject and personalmsg as I start to loop thru the form variables in my perl script, it looks like this:

emailsubject:
hi++++++Testing++++again is hi++++++Testing++++again

personalmsg:
hi+%0D%0A++there.%0D%0Atesting%0D%0A++++++++++++again.%0D%0A++++*+1%0D%0A++++*+2%0D%0A++++*+3 is hi+%0D%0A++there.%0D%0Atesting%0D%0A++++++++++++again.%0D%0A++++*+1%0D%0A++++*+2%0D%0A++++*+3

Here is some code which does some formatting with the names and values of the fields.

$name =~ s/%(..)/pack(&quot;c&quot;,hex($1))/ge;
$name =~ s/\+/ /g;


$value =~ s/%(..)/pack(&quot;c&quot;,hex($1))/ge;
$value =~ s/\+/ /g;

When I print out the personal msg value after this code it is stripped to one space in between each word.

hi there. testing again. * 1 * 2 * 3 is hi there. testing again. * 1 * 2 * 3

The emailsubject also looks stripped:

hi Testing again

The emailsubject when it is in my email looks like:


hi TESTING again


The personalmsg when it is in my email looks like:

hi there. testing again. * 1 * 2 * 3


So, I am at my wit's end (be that what it is) and I dont know what I am doing wrong. Any help would be GREATLY appreciated.

If you need any further info just ask.

Thanks!
Mrs B
 
One more thing. I enter it with spaces. No tabs or funky characters. Just type it in with spaces.
 
I can't seem to see whats wrong, but one thing you could try to see if something is typed wrong somewhere is moving the pack(&quot;c&quot; ... statement out of the regexp and assign it to a variable and then place the variable in the regexp. Be sure to remove the /e though. That won't solve the problem but may help you debug it. --Derek

&quot;Fear not the storm for this is where we grow strong.&quot;
 
I figured it out. It had to do with how the line feeds were handled. In the above case, they were removed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top