PDA

View Full Version : spaces in perl scripts


sarah_anne
02-21-2003, 09:37 AM
sub PostMessage
{
{$re = $QUERY{'re'};}

my($Replyto, $type, $formaction);
$type = @_[0];
if($QUERY{'post'})
{$Replyto = $QUERY{'post'};}
else {$Replyto = 0;}
if($type eq 'New') # If type = New, make the form send information to postnew
{
startpage('Post New Message',$SETTINGS{'backgroundcolor'},$SETTINGS{'textcolor'});
}
if($type eq 'Reply') # if type = Reply, make the form send information to postreply
{
startpage('Post Reply Message',$SETTINGS{'backgroundcolor'},$SETTINGS{'textcolor'});
}
ShowUserInfo();
starttable(500);
$formaction = qq!master.cgi?action=PutPost&location=$QUERY{'location'}&collapse=1&user=$USER{'username'}!;
print <<POSTFORM;
<form action=$formaction method="POST">
<center><font size=+2><b>Post $type Message</b></font></center>
<hr width=100%>
<br>
POSTFORM
if($SETTINGS{'accounts'} eq 'fullpublic' && $USER{'rights'} ne 'administrator')
{
print qq*Name: <input type="text" size=20 name="name" maxlength=20><br><br>E-Mail Address: <input type="text" size="30" name="email" maxlength=40><br>*;
}
print <<ENDFORM;
<br>
Subject: <input type="text" size=50 name="subject" maxlength=50 value="Re: $re"><br>
<br>




Hello -

As you can see from the code above, I have a script where a user clicks on a link similar to myfile.cgi?re=Hello All!

The text string for the value of re= is placed automatically into the textarea of the next page with Re: in the front.

So if a user had clicked myfile.cgi?re=Hello All!

then the textbox would display Re: Hello All!

But there's a problem I don't know how to fix....


If the value from re= has a space (and it more than normally does) this gets translated into the %20 sign for a space in the textbox... not very nice looking and most of my users would freak if they saw that, thinking something was wrong probably... so, how do I get it so that in the textbox is displayed a normal space and not this %20 sign...??

Thanks for any help!

sarah_anne
02-21-2003, 09:47 AM
oh, dear, not any sooner had I just posted than I found something on the internet telling me exactly how to do it :(

Simply

$re =~ s/\%20/ /g;
right?

*sheepish*

;)

Sarah.