#!/usr/bin/perl use strict; use warnings; my @full_authors = ( "Smith, John", "Smith, John Ronald", "Johnson, James", "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"; }