I have two lists of files. File list A is a list of files that have been transferred. File list B is
a list of all files in a given directory. What I want to find is an item from list B that does not exist
anywhere in list A. I just can't quite get my head around how to approach the problem.
@rray1=('one','red','orange','brown','green','blue','scarlett','fourte
+en');
@rray2=('red','orange','yellow','green','blue','indigo','violet');
foreach my $check (<@rray1>) {
foreach my $item (<@rray2>) {
if ($check ne $item) {
<do something>
}
}#close foreach
The problem with this approach is pretty obvious: 'one' does not match anything in the second list, which would be what I want.
However, 'red' matches 'red' but also shows as not matched on everything else. Basically, I think what I want is to find a string
wherever it is in an array. I've tried playing with hashes (also grep) on this to see if the solution might be in
that direction, but I'm at a loss as to where to go from here. I just need a prod in the right direction, not a full-blown solution.
thanks
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.