Deleting elements in a perl array without index
<p>I have an array which contains several strings. There is another array which contains strings which may or may not be contained in the first array. </p>

<p>What is the best way to remove any instances of a string in array b from the strings in array a. I have tried to use grep as in the example below but it completely empties the array. </p>

<pre><code>my @Aray = ('Chris', 'John', 'Paul', 'Max', 'Jim', 'John');
my @Bray = ('Chris', 'John');
foreach $name (@Bray){
    @Aray = grep {$_ != $name} @Aray;
}
</code></pre>

<p>This would result in no elements left in @Aray, opposed to 'Paul', 'Max', 'Jim'</p>

<p>I also tried with a traditional for loop and indexing each name in @Bray with the same result. </p>