in reply to how extract and group data in a array
To show TIMTOWTDI, I tried to play with a dynamic dispatch table:
#!/usr/bin/perl use strict; use warnings; my @dd = qw/AA JJ CC M 1 1 3 4 D JJ 1 1 D M 3 3 4 D C M 3 3 3 D P Z/; my @results; my %dispatch = ( M => \&start ); sub empty {} sub store { push @{ $results[-1] }, $_ } sub start { %dispatch = ( D => \&stop ); push @results, []; # Start a new group. return \&store # Store the next elements. } sub stop { %dispatch = ( M => \&start ); store(); return \&empty # Stop storing the elements. } my $on_each = \∅ for (@dd) { my $change = $dispatch{$_}; $on_each = $change->($_) if $change; $on_each->($_); } use Data::Dumper; print Dumper \@results;
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|