foreach ( @names ) { my @name_parts = split; pop @name_parts if $name_parts[-1] =~ /^[a-zA-Z]\.?$/; # throw last +name away my $f_name = join ' ', @name_parts; print "$f_name\n"; }
Updated code to reflect Not_a_Number's correction, thanks!
-- Hofmator
Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re^3: Parsing out first names
by Hofmator
in thread Parsing out first names
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |