in reply to serial comma function

A superstraightforward version:
sub serial { my $last = pop; my $seclast = pop; $seclast .= ',' if @_; join('', map "$_, ", @_) . join(' and ', $seclast || (), $last); }
Update: added $seclast .= ',' if @_;

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: serial comma function
by Your Mother (Archbishop) on Apr 16, 2003 at 01:45 UTC
    nice. i'll put an adendum in about the prototype not being needed; or just kill it and put a note in about that instead.
      Yes, nice, except it doesn't work as specified. *grumble* It doesn't add an extra comma for lists of more than two elements. I don't know where I had my eyes (or my brain, for that matter) when I was testing it.

      Makeshifts last the longest.