Sonal Singhal wrote:
>
So, what I want to do is go through an existing array and break the array
into mini-arrays at any certain points (where the diff. in two bordering
values are greater than 2000).  I programmed it as a recursive function, but
I need to store all these "mini-arrays" and be able to sort them easily by
"mini-array".  The problem with the array of arrays is I cannot get it to
treat each row as an array.  Maybe if you can help me there...

Also, if I am dynamically allocating my array of arrays, how can I find out
later my index values?

Take a look at the program below. Does it help at all? Does it raise any
more questions?

Rob


use strict;
use warnings;

my @data = 'A' .. 'Z';

my @splitdata;

{
  my $subdata;

  foreach my $item (@data) {

    push @$subdata, $item;

    if (@$subdata >= 4) {
      push @splitdata, $subdata;
      undef $subdata;
    }
  }

  push @splitdata, $subdata if $subdata;
}

foreach my $subdata (@splitdata) {
  foreach my $item (@$subdata) {
    print "[$item]";
  }
  print "\n";
}

**OUTPUT**

[A][B][C][D]
[E][F][G][H]
[I][J][K][L]
[M][N][O][P]
[Q][R][S][T]
[U][V][W][X]
[Y][Z]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to