in reply to Perl 'grammar'
I'll leave what's going on as an exercise to the reader (hint: perlre), but as a short comment, I'll say that string matching in Perl shouldn't look like string matching in C. :)sub format_name_for_AD { my $empl_name = shift; # $empl_name has the form "Last, + First" my ($last, $first) = $empl_name=~/^([^,]+), (.+)/ or return undef; return uc(substr($first, 0, 1)) . ucfirst($last); } for ('Smith, John', 'Wall, Larry', 'Perlis, Alan', 'Ritchie, Dennis') +{ print format_name_for_AD($_), "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl 'grammar'
by WoodyWeaver (Monk) on Jan 08, 2008 at 22:28 UTC | |
by gamache (Friar) on Jan 09, 2008 at 16:26 UTC | |
by WoodyWeaver (Monk) on Jan 09, 2008 at 20:09 UTC | |
by gamache (Friar) on Jan 10, 2008 at 18:10 UTC | |
by WoodyWeaver (Monk) on Jan 10, 2008 at 18:42 UTC | |
by Porculus (Hermit) on Jan 11, 2008 at 21:00 UTC | |
by WoodyWeaver (Monk) on Jan 12, 2008 at 21:58 UTC |