Perlfunc: Proper

Perl function to take take make it proper case. This should just capitalize the first letter of every word.

sub proper {
    my ($string) = @_;
    my @new_words,$word,@words,$new_string;

    @words = split (/\s/, $string);
    foreach $word (@words) {
        $new_word = ucfirst lc $word;
        push (@new_words, $new_word);
    }
    $new_string = join(" ", @new_words);
    return ($new_string);
}
Leave A Reply
All content licensed under the Creative Commons License