sub titlecase { my @P = qw(a an the and or nor of with under over from for behind on in beside at to within de del la las los); my $name = shift; my @words = split /[._ ]/, $name; my $particles = join('|', @P); foreach (@words) { $_ = ucfirst($_) if not /^($particles)$/i } $words[0] = ucfirst($words[0]); $words[-1] = ucfirst($words[-1]); return join(' ', @words); }