I presume your problem is that you have the names stored disassembled in an array. So reassemble the names using a character that won't occur in the name text as a part separator, perform the fix up, then disassemble the string again:
use strict; use warnings; my $match = join '|', 'Von', 'De La', 'De', 'La'; my @names = map {chomp; [split]} split "\n", <<NAMES; Daniel R Von Vanderschmidt Daniel Von Vanderschmidt Daniel De La Silvia Daniel De Silvia Daniel La Silvia NAMES for my $name (@names) { my $nameStr = join '~', @$name; $nameStr =~ s/~($match)~/~$1 /g; $name = [split '~', $nameStr]; } print join ('|', @$_), "\n" for @names;
Prints:
Daniel|R|Von Vanderschmidt Daniel|Von Vanderschmidt Daniel|De La Silvia Daniel|De Silvia Daniel|La Silvia
In reply to Re: Dealing with Names
by GrandFather
in thread Dealing with Names
by walkingthecow
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |