in reply to Re: Dealing with Names
in thread Dealing with Names

@name_breakdown=split(/ /,$new_gecos); if ($name_breakdown[1] eq "de" || $name_breakdown[1] eq "von" || $name +_breakdown[1] eq "van" or $name_brea kdown[1] eq "der" || $name_breakdown[1] eq "la" || $name_breakdown[1] +eq "del" || $name_breakdown[1] eq "el" || $name_breakdown[1|2] eq "le") { if ($name_breakdown[2] && $name_breakdown[3]) { $name_breakdown[1] = join(' ', $name_breakdown[1], $name_breakdow +n[2], $name_breakdown[3]); @END = splice(@name_breakdown, -2); } else { $name_breakdown[1] = join(' ', $name_breakdown[1], $name_breakdow +n[2]); pop @name_breakdown; } }
This does not work because what if there is a middle intial (Daniel R De La Silva), it messes up. It does work if it is "Daniel De La Silva" though.

Replies are listed 'Best First'.
Re^3: Dealing with Names
by apl (Monsignor) on Aug 28, 2008 at 19:39 UTC
    • Turn the above into a subroutine, passing the subscript of $name_breakdown you wish to test (rather than 1).
    • Modify the code to use the parameter, rather than hardcoding 1, 2, and 3.
    • Return whether or not not the replacement took place.

    Call the routine with a parameter of 1. If it does not do the replace, call it with a parameter of 2.
    (If you're really ambitious, store the name prefaces in a hash, and use the hash as a test. Sooner or later, the list will change...)