You're using the escape sequence \w to match characters in the surname. \w matches the characters A-z, a-z, 0-9 and the underscore (_). Your example contains a dash (-) character, so you'll need to add that to the list of allowed characters. Something like this will work:
s/^([A-Z])\w*( [-\w]+)$/$1.$2/gPerl Training in the UK <http://www.iterative-software.com>
In reply to Re: Parsing Names in a Text File
by davorg
in thread Parsing Names in a Text File
by Perl Newby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |