|
|
|
|
|
by chromatic
5631 days ago
|
|
A modern Perl programmer might write something much more elegant: my $x = 'Apple Carrot Banana';
my @y = $x->split(' ')->sort;
if (@y > 2) {
say "we've got ${\@y->size} elements!";
} else {
say "insufficient elements. fail.";
}
|
|
One of the reasons I personally like Perl is I can use which ever one is appropriate to the problem domain.
Edit: forgot the `sort` call.