jeffcol
05-13-2003, 04:33 AM
Could somebody please tell me what command is used in Perl to put text in lower case format. Let's say I have $text = "AbCdEfG". How can I make that value equal to "abcdefg"?
![]() | View Full Version : Low case jeffcol 05-13-2003, 04:33 AM Could somebody please tell me what command is used in Perl to put text in lower case format. Let's say I have $text = "AbCdEfG". How can I make that value equal to "abcdefg"? MadRaptor 05-13-2003, 06:22 AM I believe you would use $text=~ tr/[A-Z]/[a-z]/; to translate capitals into lowercase. jeffcol 05-13-2003, 03:36 PM Thank you for the advise. What I am trying to do is put all email addresses that my script works with into lower case. So that, for example, email address AbCd222@AoL.CoM would be changed into abcd222@aol.com. When I apply the command that you suggested to email addresses, the simbol @ ruins it all. In my example, address AbCd222@AoL.CoM would be changed into abcd222.com. Could somebody please suggest how I can make this work? Melitaweb 05-13-2003, 03:55 PM doesn't 'lc' work? eg lc $string; jeffcol 05-13-2003, 05:26 PM No, I get the same result. The code below gives me "abcd222.com" instead of "abcd222@aol.com". $text = "AbCd222@AoL.CoM"; $text = lc $text; Melitaweb 05-13-2003, 06:28 PM You can escape sequence the @ sign using the \ character. $text = "AbCd222\@AoL.CoM"; $text = lc $text; print $text; will display abcd222@aol.com Alternatively use the ' instead of " ie $text = 'AbCd222@AoL.CoM'; $text = lc $text; print $text; will display abcd222@aol.com PUBH 05-13-2003, 06:55 PM I haven't been able to try this yet because I do not have FTP on my laptop to upload this and try it, but I believe the following should work. //The following variable is the email address (for example) //that you would want to make all lowercase. $str_email = "AbHdCgYeefE@aol.com"; //Below is another variable which takes in the above variable //and should make it all lowercase. $str_conv = strtolower($str_email); //From this point you could echo/print the above variable if you //wish to display it. You can use it to enter into a database //instead of the direct user input. ect Again, sorry if it does not work; but I am unable to test that at the moment. Lightwave 05-13-2003, 06:55 PM Originally posted by jeffcol No, I get the same result. The code below gives me "abcd222.com" instead of "abcd222@aol.com". $text = "AbCd222@AoL.CoM"; $text = lc $text; As the previous poster stated.. this almost works... Change the "s to 's Otherwords you're interpolating the value of the AoL.CoM array. |