Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: "Use of uninitialized value in pattern match (m//)" warning, doing a grep on 2D array

by hippo (Bishop)
on Oct 14, 2022 at 14:47 UTC ( [id://11147439]=note: print w/replies, xml ) Need Help??


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

Your code as presented in the OP only filters on the first column, so that's the one to use in this pre-filter - if that's the way you want to go with this.

#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; use Test::NoWarnings; my @matrix = ( [1, 2], [undef, 9], [3, 4] ); my $to_keep = 3; my @matrix_defined = grep { defined $_->[0] } @matrix; is $#matrix_defined, 1, '2 rows after prefilter'; my @matrix_filtered = grep { $_->[0] =~ /$to_keep/ } @matrix_defined; is $#matrix_filtered, 0, '1 row after full filter';

🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147439]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-29 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found