#!/usr/bin/perl -w use strict; for (qw(mcginley macgee develera)) { print "$_ => ".handle_caps($_)."\n"; } sub handle_caps { # this assumes irish capitalisation! my $name = ucfirst(shift); for (qw(Mc Mac)) { # always ok $name =~ s/^$_(.*)/$_\u$1/; } for (qw(De)) { # may not be followed by [aoeiu] # ?? don't know enough irish # for this rule ;-) $name =~ s/^$_([^aoeiu].*)/$_\u$1/; } return $name; }