Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Data::Dumper; my @names = [ "Mark K.", "Bob H", "Kurt", "Mary Kay K", "Mary Jo Z.", "Mary Jo" ]; foreach my $name ( @names ) { my $f_name = $name =~ m/(.*)[a-zA-Z]/; print "$f_name \n"; } # @names with only first names would look like: # my @names = [ "Mark", "Bob", "Kurt", "Mary Kay", "Mary Jo", "Mary Jo" ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing out first names
by prasadbabu (Prior) on Oct 13, 2006 at 05:23 UTC | |
|
Re: Parsing out first names
by ysth (Canon) on Oct 13, 2006 at 04:44 UTC | |
|
Re: Parsing out first names
by grep (Monsignor) on Oct 13, 2006 at 04:44 UTC | |
by driver8 (Scribe) on Oct 13, 2006 at 07:17 UTC | |
by Hofmator (Curate) on Oct 13, 2006 at 07:42 UTC | |
by Not_a_Number (Prior) on Oct 13, 2006 at 09:19 UTC | |
by driver8 (Scribe) on Oct 13, 2006 at 12:03 UTC | |
|
Re: Parsing out first names
by McDarren (Abbot) on Oct 13, 2006 at 04:42 UTC | |
|
Re: Parsing out first names
by awohld (Hermit) on Oct 13, 2006 at 04:54 UTC | |
by driver8 (Scribe) on Oct 13, 2006 at 07:10 UTC | |
|
Re: Parsing out first names
by johngg (Canon) on Oct 13, 2006 at 14:15 UTC | |
|
Re: Parsing out first names
by swampyankee (Parson) on Oct 13, 2006 at 17:49 UTC |