You're right, it should probably be called 'mixed case'.
sub sentance {
my $s = shift;
$s =~ s/^(\w)(.+)$/\U$1\L$2/g;
return $s;
}
sub mixed {
my $s = shift;
$s =~ s/\b(\w)(\w+)\b/\U$1\L$2/g;
return $s;
}
sub headline {
my $s = shift;
$s =~ s/\b(\w)(\w+)\b/length($2)>2?uc($1).lc($2):lc($1.$2)/eg;
return ucfirst($s);
}
chomp(my @sentances = <DATA>);
foreach my $fn (qw(sentance mixed headline)) {
print $fn, "\n";
foreach my $s (@sentances) {
print "\t", &{$fn}($s), "\n";
}
}
__DATA__
this is a test
this is a headline
blah blah BLAH blah
the cat sat on the mat
we are all brothers at perlmonks
gav^