#!/usr/bin/perl -w
use strict;
my $str = 'Mariel Miller,Allyson Fiona Hadwin,Jenna Cambria';
my @authors =
($str =~ /\s*(.*?)\s*<\/P_contrib-author>/g);
if (@authors >= 3)
{
print join (", ", @authors[0..@authors-2]),
" and $authors[@authors-1]\n";
}
elsif (@authors == 2)
{
print "$authors[0] and $authors[1]\n";
}
else
{
print "$authors[0]\n";
}