If that's the way things are, then maybe:
>perl -wMstrict -le
"my $str = 'eternal corruption defilement';
;;
$str =~ s{ \b ([[:alpha:]]) [[:lower:]]* \s* }{\U$1}xmsg;
;;
print qq{'$str'};
"
'ECD'
Update: Removed an unnecessary level of capture grouping in regex above. Also: [[:lower:]]* might be better as [[:alpha:]]* instead.
Update: Or even:
>perl -wMstrict -le
"my $str = 'eternal corruption defilement';
;;
$str =~ s{ (\b [[:alpha:]]+ \s*) }{ uc substr $1, 0, 1 }xmsge;
;;
print qq{'$str'};
"
'ECD'
|