Revision: 30150
Updated Code
at August 27, 2010 11:07 by davidmoreen
Updated Code
#!/usr/bin/perl -w
use strict;
use 5.010;
my ($type, $string);
print "What type of case? (upper/lower):\n";
while (<STDIN>) {
chomp;
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" }
}
print "\n";
Revision: 30149
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 9, 2010 08:20 by davidmoreen
Initial Code
#!/usr/bin/perl -w
use strict;
use Switch;
my ($input, $type, $string);
print "What type of case? (upper/lower):\n";
while (<STDIN>) {
chomp;
if ($_ ne ("upper" || "lower")) {
print "Invalid type please type upper or lower:\n";
} else {
$type = $_;
last;
}
}
print "Please enter your text:\n";
chomp($string = <STDIN>);
switch ($type) {
case "upper" { print uc $string }
case "lower" { print lc $string }
}
print "\n";
Initial URL
Initial Description
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) :]
Initial Title
Changing text case utility
Initial Tags
text
Initial Language
Perl