in reply to using grep with two dimensional arrays
For this, you will need to loop over your array - using both indices - something like the following untested code:
#!/usr/bin/perl -w use strict; my @array = (); #actually use code that creates 2d array for ( my $i = 0; $i <= $#array; $i++) { for ( my $j = 0; $j <= $#{$array[$i]}; $j++ ) { if ($array[$i][$j] =~ /something/) { # Do something with $array[$i][$j] } } }
Hope this helps point you in the right direction. I really like our Q/A section at PM, the http://www.perlfaq.com FAQ, and the http://www.perldoc.com FAQ.
Cheers - L~R
Update: Code now tested. As others have shown, if you do not need the indices and need only the row - other methods work with grep.
|
|---|