in reply to Format a list with commas and "and"
What about this?
Fixed squiggly brackets and should be $" not $,.sub andify { return '' unless @_; return $_[0] if @_ == 1; local $" = @_ == 2 ? ' ' : ', '; $_[-1] = 'and ' . $_[-1]; return "@_"; }
20050525 Edit by ysth: p, code tags
|
|---|