Friday, September 28, 2012
10:45 PM

Perl Script: Convert any given string To-Lower or To-Upper case

Below is simple perl script which converts any given string to Upper or to-Lower case ...
Here, we have used the perl Escape Sequence ( \U \L \E)

\U -- Convert all following letters to Uppercase
\L -- Convert all following letters to Lowercase
\E -- Ends the effect of \L, \U or \Q

Feel free to copy and use this code ...

Source: cat case-conversion.pl
#!/usr/bin/perl

print "Enter the string: ";
$var = <STDIN>;

print "To uppercase: \U${var}\E \n";
print "To lowercase: \L${var}\E \n";

Output: perl case-conversion.pl
Enter the string: LinuxPoison
To uppercase: LINUXPOISON
To lowercase: linuxpoison


0 comments:

Post a Comment