in reply to regex help
Here is simple regexp. Let me know if there is any mistake.
No need to use Second array i.e. @author.
#!/usr/bin/perl use strict; use warnings; my @full_authors = ( "Smith, John", "Smith, John Ronald", "Johnson, Ja +mes", "James, Ray Jack", "Van der Burg, Jon", "O'Neil, Sarah" ); foreach my $author(@full_authors) { my $fullauthorname=$author; while ($author=~s#(, .*?[A-Z])[a-z]+\s*#$1#) { } $author=~s#,##g; print "\n$author = $fullauthorname"; }
Regards,
Gopal.R.
|
|---|