Hello, I'm relatively new to PERL and have a pretty basic question.

I personally believe that the very fist thing you should know is that it's not PERL.

Is GREP usable in this instance?

It's certainly usable. But it all depends on the code you tell it to execute. One common technique to check whether and item belongs to an array used to involve another grep, but that would be inefficient, since it would iterate over all items of the bad list. Thus a better choice would be List::Util's first() which stops as early as an item is found. With 5.10, however, you have a specialized operator to do this kinda things: ~~:

#!/usr/bin/perl use strict; use warnings; use 5.010; my @goodstuff=1..5; my @badstuff=(1,3); my @newstuff = grep !($_ ~~ @badstuff) => @goodstuff; say "@newstuff"; __END__

Incidentally, to refer to the grep() function, you don't need to capitalize its name and better would not, since it has little to no sense at all, given that Perl is case sensitive. Instead, here, you can link to its documentation like I did above by inserting the following code in the source of the post: [doc://grep]. Alternatively you can use the trick one commonly adopts in pure text contexts of adding a pair of parens to remind that it's a function, optionally putting it in code tages -here at the monastery- to remind that it's supposed to be code, as in: <code>grep()</code>.

--
If you can't understand the incipit, then please check the IPB Campaign.

In reply to Re: Subtracting Lists by blazar
in thread Subtracting Lists by JimSki

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.