RosettaCodeData/Task/Comma-quibbling/Perl/comma-quibbling-1.pl
2023-07-01 13:44:08 -04:00

8 lines
227 B
Perl

sub comma_quibbling :prototype(@) {
return "{$_}" for
@_ < 2 ? "@_" :
join(', ', @_[0..@_-2]) . ' and ' . $_[-1];
}
print comma_quibbling(@$_), "\n" for
[], [qw(ABC)], [qw(ABC DEF)], [qw(ABC DEF G H)];