in reply to Re^3: Use grep with two arrays
in thread Use grep with two arrays
When you process @array2, @array1 is presumably shorter than it used to be -- the elements of the two arrays are no longer in parallel (assuming they were parallel before the first grep operation). You'll be getting the wrong elements left behind in @array2 (only the last elements of @array2 will ever be removed).@array1 = @array1[+grep { $array1[$_] =~ /keep these/ } 0 .. $#array1 ]; @array2 = @array2[+grep { $array1[$_] =~ /keep these/ } 0 .. $#array1 ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Use grep with two arrays
by QM (Parson) on Feb 15, 2006 at 20:53 UTC |