sub print_with_ands { my $x=0; my $a=shift; printf "$a->[$x-1]%s", defined $a->[$x+1] ? ", " : ! defined $a->[$x] ? "\n" : $x==1 ? " and " : ", and " while defined $a->[$x++]; }