in reply to serial comma function
I think it'd look cleaner with a pop, too.sub serial { join(', ', @_[0 .. $#_-1]) . (@_ > 2 ? ',' : '') . (@_ > 1 ? ' and ' : '') . $_[-1]; }
sub serial { my $last = pop; join(', ', @_) . (@_ > 1 ? ',' : '') . (@_ > 0 ? ' and ' : '') . $last; }
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: serial comma function
by Enlil (Parson) on Apr 15, 2003 at 22:56 UTC | |
by Aristotle (Chancellor) on Apr 16, 2003 at 00:04 UTC |