Changing text case utility
Just run in your consol window as ./tocase (or whatever you call the file). Be sure to give it proper permission first (chmod 755 tocase) :]
Copy this code and paste it in your HTML
#!/usr/bin/perl -w
use strict;
use 5.010;
my ($type, $string);
print "What type of case? (upper/lower):\n";
while (<STDIN>) {
if (/^(upper|lower)$/i) {
$type = $_;
last;
} else {
print "Invalid type please type upper or lower:\n";
}
}
print "Please enter your text:\n";
chomp($string = <STDIN>);
given ($type) {
when
("upper") { print "\U$string" } when
("lower") { print "\L$string" }}
Report this snippet
Comments
Subscribe to comments
Example: $~ chmod 755 tocase $~ ./tocase What type of case? (upper/lower): upper Please enter your text: hello world HELLO WORLD $~