in reply to Help to assign a 2D-Array to another while excluding specific rows.


I know a couple of you showed how to use grep for this but could someone explain how to do this Pseudo code below, just the way it is. Please nothing too complicated, having trouble understanding most of your examples.

So I would have a for loop and loop through line by line of all the records (@AoA which is a 2D-Array).
Then say, using grep, "If the current line does NOT CONTAIN any element from @SPUsers (which is a single dimension array holding a couple of names).
Then push/map the data from "the current line of @AoA" onto the end of the array @recordsToDel (also should be a 2D-Array)... Next line

I tried this below to achieve that but not sure how to do the EXPR part of the grep command. What I get is the correct amount of elements but the output when I print each element is like "Array(0x8431c84)".


#2D-Array of all the data, containg rows and columns @AoA = <DATA>; my @SPUsers = ("bill", "Bob", "Mike", "Steve", "mmartin"); my @recordsToDel; my $count = 0; for (my $x = 0; $x <= $#AoA; $x++) { if (grep ( @{ $AoA[$x] } !~ @SPUsers, @AoA )) { $recordsToDel[$count] = @{ $AoA[$x] }; } }


Please let me know if I need to explain a bit more.


Thanks,
Matt


.
  • Comment on Re: Help to assign a 2D-Array to another while excluding specific rows.
  • Download Code