note
CountZero
Building upon your very elegant solution, but changing it somewhat so it now adds to the valid output a sequence at the end that starts with a 6 but never gets ended by a 7.<p><c>use Modern::PBP::Perl;
my $aref = [1, 6, 2, 2, 7, 1, 6, 99, 99, 7, 1, 2, 6, 9, 8, 6, 5];
my @copy;
my @stack;
(($_ == 6 .. $_ == 7) and push @stack, $_) or (push @copy, $_ and @stack=()) for @$aref;
push @copy, @stack;
use Data::Dumper;
print Dumper \@copy;
</c><!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-198160">
<p>CountZero</p><p><i>A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity."</i> - [http://www.canonical.org/~kragen/tao-of-programming.html|The Tao of Programming], 4.1 - Geoffrey James</p>My blog: [http://imperialdeltronics.wordpress.com|Imperial Deltronics]
</div></div>
1193467
1193482