#!/usr/bin/perl -w use strict; # List your exceptions here my @exceptions = qw(the and or); while (my $str = ) { print "Input: ", $str; # Substitute the text in quotes $str =~ s{(")([^"]+)(")} {$1 . join('', map ucfirst, split /(\s+|[-])/, $2) . $3}eg; # lc the exceptions that don't start a title $str =~ s/ $_\b/ $_/gi for @exceptions; print "Output: ", $str, "\n"; } __DATA__ "red hot chili peppers" (group), "by the way" (album title). "the go-betweens" (group), "spring hill fair" (album title). "jonathan richman" (group), "i, jonathan" (album title).