G'day David,
You can use various features of Perl to write that very succinctly:
$ perl -E 'say "Name: @{[map ucfirst, split]}" while <>'
billy bob allen
Name: Billy Bob Allen
abc pqr wxyz
Name: Abc Pqr Wxyz
Features (some of which you probably already know about):
-
$_: used in various places here; the first is the line read by while.
-
split: defaults to splitting $_ on whitespace (it's a little more involved than that — see doco link for full details).
-
ucfirst: defaults to operating on $_.
-
Baby cart: that's the @{[...]} part — interpolates a list within a string.
-
$": list separator — defaults to space separation.
-
say: print plus newline; requires 5.10 or later.