use warnings; use strict; sub non_oxford_list { my ($s) = @_; my $p = rindex $s, ','; substr ($s,$p,1) = " and" if $p > -1; return $s; } use Test::More tests => 3; is non_oxford_list('A'), 'A'; is non_oxford_list('A, B'), 'A and B'; is non_oxford_list('A, B, C'), 'A, B and C';