I convert to upper, lower, or mixed-case with these routines:
# perl0006.lib
# Written: 1999-07-13 James Alarie
#
# caseu, casel, casem
sub casel{ # lower case
$_[0] =~ tr/A-Z/a-z/;
return $_[0];
}
sub casem{ # mixed case
local($ch, $in, $ix, $out, $uc);
$in = $_[0];
$in =~ tr/A-Z/a-z/; # make it lower case
$uc = 'no'; # no uppercase yet
$out = ''; # nothing out yet
for ($ix = 0; $ix <= length($in); $ix++) {
$ch = substr($in, $ix, 1); # get a character
if ($ch =~ "[a-z]") { # is a letter
if ($uc eq 'no') { # no uppercase yet
$ch =~ tr/a-z/A-Z/; # this is uppercase
$uc = 'yes'; # now we have one
}
} else {
$uc = 'no'; # no uppercase yet
}
$out .= $ch; # add to output
}
return $out;
}
sub caseu{ # upper case
$_[0] =~ tr/a-z/A-Z/;
return $_[0];
}
#***** Accessed correctly:
1;