Sunday, March 20, 2011

Lowercase and Uppercase in Perl

Lowercase and Uppercase in Perl
All the programming languages has functions/methods to convert case to upper or lowercase.
Perl has lc for lowercase, uc for uppercase, ucfirst for first character to be converted to uppercase. etc...
Let see some examples :
#!/usr/bin/perl -w
$name = "firat serkan atagun";
$ucname= uc ($name);
$lcname = lc ($name);
$ucfname = ucfirst ($name);

print $name."\n".$ucname."\n".$lcname."\n".$ucfname;

The output will be :
firat serkan atagun
firat serkan atagun
FIRAT SERKAN ATAGUN
Firat serkan atagun


uc
function is used for converting strings in to uppercase.
lc function is used for converting strings in to lowercase
ucfirst function is used for converting the first chracter of the string to uppercase.

No comments:

Post a Comment