in reply to Re^2: Use grep with two arrays
in thread Use grep with two arrays

And to avoid the temp variable — not really a valid goal, but kind of fun — and not repeat the grep:
my @a1 = qw'only keep ones that have es'; my @a2 = qw'art bart cart dart eart good'; @a1 = @a1[sort {$a <=> $b} grep {$a1[$_] =~ /e/ or do { splice @a2, $_ +, 1; 0 } } reverse 0..$#a1]; print "@a1\n@a2\n";
It gets a little complicated, mostly because of the gyrations necessary to splice out the right element after others have been removed.

Caution: Contents may have been coded under pressure.