CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
ALL CAPS?

 



Gregorio
User

Aug 6, 2000, 3:21 PM

Post #1 of 2 (401 views)
ALL CAPS? Can't Post

Is there a way to make all letters in a string be in CAPS?


Kanji
User / Moderator

Aug 6, 2000, 3:45 PM

Post #2 of 2 (401 views)
Re: ALL CAPS? [In reply to] Can't Post

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

$string = uc $string;
$string = "\U$string";
$string =~ tr/a-z/A-Z/;</pre><HR></BLOCKQUOTE>

Pick your poison, although I'd be inclined to lean towards the uc or \U (which can also be used inside s///) methods depending on the application.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

print uc $string; # prints in uppercase


$string = "this";
$string =~ s/(.*)is/\U$1at/; # change this to THAT</pre><HR></BLOCKQUOTE>

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives