Code:
$
$
$ perl -e '@x = (1,2,3,4,5,6,1,2,3,4,1,2,1,2,3,4,5,6,7,8,9);
@y = grep {$x[$_] > $x[$_+1]} (0..$#x);
foreach $i (0..$#y) {
$begin = $i == 0 ? 0 : $prev+1;
$end = $y[$i];
printf ("%-30s BEG=%-2s END=%s\n", "(".join(",", @x[$begin..$end]).")", $begin, $end);
$prev = $end;
}
'
(1,2,3,4,5,6) BEG=0 END=5
(1,2,3,4) BEG=6 END=9
(1,2) BEG=10 END=11
(1,2,3,4,5,6,7,8,9) BEG=12 END=20
$
$
$