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


.

In reply to Re: Help to assign a 2D-Array to another while excluding specific rows. by mmartin
in thread Help to assign a 2D-Array to another while excluding specific rows. by mmartin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.