I have a cript which creates Unix users. The problem is that the source data can be in any state and I want to change the gecos (real name) to title case. i.e. whether the input is FRED BLOGS, fred blogs or Fred Blogs it should end up as Fred Blogs
So far I've got
which works but it's not very pretty and there must be a better way using regex. Sommething along the line of
but that doesn't do what I thought it would (and, of course, misses out the first name) Any pointers please?
Ceci n'est pas une signature
Columb Healy
So far I've got
Code:
my @bits;
foreach ( split / /, $gecos )
{ push @bits, ucfirst ( lc ( $_ ) ); }
$gecos = join ' ', @bits;
print "$gecos\n";
Code:
$gecos = lc $gecos;
$gecos =~ s/\s(\w)/uc($1)/g;
Ceci n'est pas une signature
Columb Healy