Results 1 to 10 of 10

Thread: CGI and Lcase

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Iowa
    Posts
    73

    Question 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!


  2. #2
    scoutt
    Guest
    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.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Iowa
    Posts
    73

    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. =]

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Iowa
    Posts
    73

    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?

  5. #5
    scoutt
    Guest
    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.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Iowa
    Posts
    73

    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!

  7. #7
    scoutt
    Guest
    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

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Iowa
    Posts
    73

    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.

  9. #9
    scoutt
    Guest
    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

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Location
    Iowa
    Posts
    73

    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
  •  



Click Here to Expand Forum to Full Width