use strict; my $title = "this and that are the way to go"; $title = make_a_title( $title ); print $title; sub make_a_title { my $title = shift; my @nocapslist = qw( in and the for it but to with about or nor because as that ); my %nocapslist; @nocapslist{ @nocapslist } = undef; my @wordlist = split /\s+/, $title; $wordlist[0] = ucfirst $wordlist[0]; foreach (@wordlist) { $_ = ucfirst if ! exists $nocapslist{ $_ }; } return join ' ', @wordlist; }