in reply to Format a list with commas and "and"

My version. What can I say, I like the ? : operator :)

Usage: &print_with_ands(\@array);

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++]; }