Personally, I find a "C style" loop for a loop that uses gbacon that often unnecessarily complicates the code. And, as a rule, you can replace it with a "range-style" for a loop that is easier to complete.
use strict;
use warnings;
my @arr = qw(0 1 2 3 4);
my @result;
for my $i (0 .. $#arr) {
for my $j ($i .. $#arr) {
push @result => [ @arr[$i .. $j] ];
}
}
print @$_, "\n" for @result;
source
share