in reply to Re^3: Question of scope and syntax
in thread Question of scope and syntax
The special variable, "$_" is used both by grep, and by foreach. Write your loop like this:
foreach my $dir_try ( @copyOfContentsOfDirectory ) { push @pdfNoMatchingDirectory, grep { $_ ne $dir_try } @contentsOfD +ataBase; }
The 'it' variable ($_) from your foreach loop is being masked by the it variable from the grep. This avoids that situation. Also, on each loop iteration, @pdfNoMatchingDirectory is being reset with a new list from grep. I added push so that @pdfNoMatchingDirectory instead accumulates all the elements you're looking for. That may not be what you're after, so you might remove the push again.
You know, I keep seeing the word DataBase in your variables. It would probably be more efficient to use your SQL database's SQL engine to perform the set-symmetric-difference task.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Question of scope and syntax
by Hellhound4 (Novice) on May 03, 2012 at 17:47 UTC |