title: How to store variable-arrays inside another array?
body: <p>I have a perl-query on saving arrays inside another array. A related query was asked before(<a href="https://stackoverflow.com/questions/1025342/">How do I add an array ref to the middle of an existing array in Perl?</a>), but I could not find answer to mine, so I am posting it here.</p>
  
  <p>I have 10 text files, each having approximately 100 lines of text. I want to pick all those lines containing the word "important". Script for doing this operation is below. I save all lines containing word "important" in an array. So, from each text file, I get an array. I want to save all those arrays inside another array ?</p>
  
  <pre><code>my @list_of_files = ("input1.txt", "input2.txt","input3.txt"); my $list_of_files = @list_of_files;
  
  for ($file=0, $file&lt;$list_of_files; $files++){
   open INPUT_FILE, "$list_of_files[$file]" or die "can't open $file : $!";
   my @input = &lt;INPUT_FILE&gt;;
   my $size = @input;
  
   for ($num=0; $num&lt;$size; $num++){
    if ($input[$num] =~ m/important/) {
     push (@sub_array, $output);
    }
   }
   close INPUT_FILE;
   push (@main_array, \@sub_array);   
  }
  </code></pre>
  
  <p>elements of @sub_array changes every time, so, how do I preserve elements of all sub_arrays ? I would like to have final output as @main_array, which contains 3 elements, each element is an array of elements (lines containing the word "important")</p>
  
  <p>Any help is much appreciated TIA</p>