Perl Tutorials -Part 49- Changing case

Posted on June 2, 2010. Filed under: Perl Tutorials |


#perl example of lc function -- lower case
$jumbled = 'wHy aREN\'T i pROPERlY CAsED?';
$sorted = lc ($jumbled);
print $sorted;
print "\n";

#perl example of uc function -- upper case
$original = 'jUMbLeD Up cASE!';
$upperCase = uc ($original);
print $upperCase;
print "\n";

#perl example of ucfirst function -- upper case for only first character
$original = 'capital first letter.';
$initialUpper = ucfirst ($original);
print $initialUpper;
print "\n";

#perl example of lcfirst function -- lower case for only first character
$original = 'No need for caps.';
$initialLower = lcfirst ($original);
print $initialLower;
print "\n";

Output:

1
2
3
4
why aren't i properly cased?
JUMBLED UP CASE!
Capital first letter.
no need for caps.
Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: