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

8 lines
209 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)];