RosettaCodeData/Task/Comma-quibbling/Perl/comma-quibbling-2.pl
2015-02-20 09:02:09 -05:00

8 lines
208 B
Perl

use 5.01;
sub comma_quibbling{
my $last = pop // '';
return '{'. (@_ ? (join ', ', @_).' and '.$last : $last).'}';
}
say for map {comma_quibbling(@$_)}
[], [qw(ABC)], [qw(ABC DEF)], [qw(ABC DEF G H)];