|
-
May 17th, 2001, 04:56 PM
#1
Thread Starter
Lively Member
CGI and Lcase
Is there a way I can make a string lcase in CGI? The textbox is "mess" and I want to get the string they enter to be Lcase no matter what. They can enter the sting LIKE ThIs but when it reads it it converts it all to Lcase. How would I do this? I've looked all through my book and looked on the internet but have found no answers. Thanks a bunch!
-
May 17th, 2001, 07:57 PM
#2
you are saying that when somebody enters text in capitols that cgi will convert it to lower case? why would you want to do it if it already does it.
-
May 18th, 2001, 12:43 AM
#3
Thread Starter
Lively Member
ok
So if I just wanted to do it this way I would put...
$lmess = "mess.toLowerCase()";
?
Maybe with that extra bit of code there you'll be able to see what I'm trying to do. Thanks a lot for your help. =]
-
May 18th, 2001, 02:35 AM
#4
Thread Starter
Lively Member
hmmm...
I'm not sure, but that code looks more like it's for java or asp. I may be wrong but I've never seen a . in a CGI script. heh.
It wouldn't per chance be
$lmess = $lcase{mess};
or something simple like that would it?
-
May 18th, 2001, 11:04 AM
#5
you're right it is not cgi. it is javascript. but you should not have any problems running it in with your cgi script. I am pretty sure there is a function for cgi to do lower case but I can't remember it right off hand. sorry
you could try that, it looks good.
-
May 18th, 2001, 02:39 PM
#6
Thread Starter
Lively Member
alright.
I don't want to send the output to the browser, I want to save it as lcase. That's shy I've got to use the CGI format. I'm still looking for an answer so if anyone can help me out real quick I'd apreciate it. Thanks!
-
May 18th, 2001, 04:11 PM
#7
got it
Code:
$lowerc =~ tr/[A-Z]/[a-z]/;
This results in $lowerc being translated to all lowercase letters. The brackets around [A-Z] denote a class of characters to match.
tr = translate command
-
May 18th, 2001, 04:30 PM
#8
Thread Starter
Lively Member
still not working...
I've got this as my sub
sub lcase {
$txt = $_[0];
$txt = ~ tr /[A-Z]/[a-z]/;
return $txt;
}
I get an error on the return $txt;
I found this code also and was just trying it but it wouldn't work. Then I added the [] around them like you said and same error. The error log says something about EOF. Not sure exactly what that is but I seem to be having a lot of problems. I can't believe this minor task is being so difficult. Thanksa lot for your help though scoutt! By the way, is that your blue scout on your site? nice.
-
May 18th, 2001, 05:10 PM
#9
thanks and yes it is my truck.
Is the $_[0] part of an array? the EOF is and "end of file" error. I'm a little confused. is this a form you are doing and when you enter text into a text box and then push send does it then store it in a database or text file? I think the EOF is because you didn't set the content length. just an idea.
could you do something like this
Code:
sub lcase{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($_[0], $value) = split(/=/, $pair);
$value =~ tr/[A-Z]/[a-z]/;
$FORM{$_[0]} = $value;
}
}
The keys of %FORM are the form input names themselves. So, for example, if you have three text fields in the form - called name, email-address, and age - you could refer to them in your script by using $FORM{'name'}, $FORM{'email-address'}, and $FORM{'age'}.
by the way I think this will only work for POST
-
May 18th, 2001, 11:23 PM
#10
Thread Starter
Lively Member
yes
Yes, it's a form. They enter text into a textbox and I want to save it to a textfile in lowercase.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|