in reply to Re: Format a list with commas and "and"
in thread Format a list with commas and "and"

Hey! You can't see the join's :)

#! perl -sw use strict; sub npAndAList{$"=', '; return unless @_; @_==1 and "@_" or "@_[0 .. $ +#_-1] and $_[-1]" } print npAndAList(qw(a b c d e)[0..$_]),$/ for -1..4; __DATA__ a a and b a, b and c a, b, c and d a, b, c, d and e

Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!