title: Create an array of arrays from a list in Perl
body: <p>I want to  create an array of arrays from a list of objects. but how to reset the array variable (@row and reuse it to hold items in the next sections)? I know the @row is declared once, when it is pushed into the array, emptying it will empty the @arrays too. How can I reset @row while not empty @arrays?</p>
  
  <pre><code> use Data::Dumper;
  
      # sample data, could be a long list for complex data types
      my @list = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
  
      my @arrays;
      my @row;
      my $numSub = 10;
  
      foreach my $itm (@$list)  {
         if (scalar(@row) == $numSub) 
         {   
            push @arrays, \@row;
            @row = (); # clear array, cleared the array of arrays
            push @row, $itm;
          }
          else {
            push @row, $itm;
         }
     }
     # push the last reminder
      push @arrays, \@row;
  
     Dumper @arrays; # nothing 
  </code></pre>