Guest_imported
New member
- Jan 1, 1970
- 0
if I have an array like this:
@data = one two three four
and I have an array of numbers which are reference numbers to the items in the first array which I want to delete (e.g. @num = 0, 2 to leave two & four in the first array), I obviously have problems doing a foreach loop:
foreach $ref (@num){
splice(@data, $ref, 1);
}
because the reference numbers of the first array change as I'm splicing them.
Does anyone know how to get round this?
@data = one two three four
and I have an array of numbers which are reference numbers to the items in the first array which I want to delete (e.g. @num = 0, 2 to leave two & four in the first array), I obviously have problems doing a foreach loop:
foreach $ref (@num){
splice(@data, $ref, 1);
}
because the reference numbers of the first array change as I'm splicing them.
Does anyone know how to get round this?