all, below is a sub i created to try to properly capitalize surnames of irish/scottish descent, converting Macarthur => MacArthur, o'donnell => O'Donnell, etc.
it works as intended but i was wondering if anyone can suggest improvements in size and efficiency (realizing the two are not necessarily compatible). also rules for any additional naming styles would be appreciated since the sites using this will have a fairly global audience, name-wise. thanks in advance, joe ############################################# print &surname(NAME => $ARGV[0]) . "\n"; # SUB SURNAME # removes leading/trailing whitespace # consolidates grouped whitespaces into single whitespaces # capitalizes first letter after "Mac/Mc/'" in name (names of Scottish/Irish descent) # capitalizes first letter of name upon return sub surname { my %options = @_; # $options{NAME} = name to capitalize internally, if appropriate # remove leading and trailing whitespace, consolidate whitespace groupings into single whitespaces $options{NAME} = join(' ', split(' ', $options{NAME})); if ($options{NAME} =~ /^M[a]*c|'/i) { $options{NAME} =~ m/c|'/g; my $pos = pos $options{NAME}; substr($options{NAME}, $pos, 1) = uc(substr($options{NAME}, $pos, 1)); } # end of if ($options{NAME} =~ /^M[a]*c|'/) return(ucfirst($options{NAME})); } # end of sub surname ############################################# -- since this is a gmail account, please verify the mailing list is included in the reply to addresses -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/