use warnings; use strict; use Integer::Partition qw(); my $i = Integer::Partition->new(6); while (my $p = $i->next()) { print join( ' ', @$p ), $/ if (@$p == 5) and not all_same(@$p); } sub all_same { my $same = 1; for (@_[1 .. $#_]) { if ($_ != $_[0]) { $same = 0; last; } } return $same; } __END__ 2 1 1 1 1