#!/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). #### Input: "red hot chili peppers" (group), "by the way" (album title). Output: "Red Hot Chili Peppers" (group), "By the Way" (album title). Input: "the go-betweens" (group), "spring hill fair" (album title). Output: "The Go-Betweens" (group), "Spring Hill Fair" (album title). Input: "jonathan richman" (group), "i, jonathan" (album title). Output: "Jonathan Richman" (group), "I, Jonathan" (album title).