in reply to "Use of uninitialized value in pattern match (m//)" warning, doing a grep on 2D array

Under the assumption that you do not want rows with undefined values in your output (however they got there):

my @matrix_filtered = grep { defined( $_->[0] ) && $_->[0] =~ /$to_keep/ } @matrix;

You could simply silence the warning, but then you will get the bogus rows in your output if '' =~ /$to_keep/ is true.

  • Comment on Re: "Use of uninitialized value in pattern match (m//)" warning, doing a grep on 2D array
  • Download Code