in reply to using grep to extract numbers from an array
This piece of code is going start grabbing elements when the first value occurs, and stop grabbing them when the second value occurs. It'll return the intervening list, irrespective of the value of those intermediate elements.
Thus:
produces 1 2 47 3my @old_array=(0, 1, 2, 47, 3); my @new_array=grep {$_==1 .. $_==3} @old_array; print "@new_array\n";
--
Tommy
Too stupid to live.
Too stubborn to die.
|
---|