in reply to Use grep with two arrays

Try this
@ary1= (1,2,3,4,3); @ary2= (a,b,c,d,u); print "Before\n"; print "@ary1","\n"; print "@ary2","\n"; $cnt=0; foreach (@ary1) { push(@new_ary,$cnt), if($_ =~ /3/); $cnt++ } splice(@ary1,$_,1,"undef"), for(@new_ary); splice(@ary2,$_,1,"undef"), for(@new_ary); @ary1 = grep{!/undef/} @ary1; @ary2 = grep{!/undef/} @ary2; print "\nAfter\n"; print "@ary1","\n"; print "@ary2","\n";
Output:
Before
1 2 3 4 3
a b c d u
After
1 2 4
a b d