in reply to Format question

You could also capitalize the names in case they are all lower case.
#!/usr/bin/perl use strict; use warnings; print ToTitleCase('barney rubble'); exit; ############################################ # v2019.12.4 # Capitalizes the first letter of every word, # and returns a new string. # Usage: STRING = ToTitleCase(STRING) # sub ToTitleCase { my $S = defined $_[0] ? lc($_[0]) : ''; my ($i, $p, $BREAK) = (-1, 0); while (++$i < length($S)) { ($BREAK = index(" .,:;!?/\\()[]{}<>|-+=\t\n\r\xFF", substr($S, $i, + 1))) >= 0 or $p < 0 or ($p = vec($S, $i, 8)) > 122 or vec($S, $i, 8) = $p & 223; $p = $BREAK; } return $S; } ############################################

Replies are listed 'Best First'.
Re^2: Format question (capitalization)
by hippo (Archbishop) on Dec 05, 2019 at 15:16 UTC

    A slightly more Perlish alternative:

    #!/usr/bin/env perl use strict; use warnings; print title_case('barney rubble'); exit; sub title_case { $_ = shift; s/\b(\w)/\U$1/g; return $_; }

    See also the FAQ.

Re^2: Format question
by Your Mother (Archbishop) on Dec 05, 2019 at 15:37 UTC

    Side note: Title case is an editorial term and procedure that is a bit more complicated than capitalizing words, the spelling of names does not have to constrain to any such rules, and uc/lc are not always uniform or roundtrippable operations outside of basic Roman letters.