Hi,
Say I have an array @a_array which contain objects which are in turn arrays with 6 elements. I am trying to delete objects from that array whose first element equals an element of another array.
So far I have got this far (assume that @a_array and @ignore_variables has been declared and populated earlier).
my $i;
my $j;
for $i (0 .. $#a_array) {
$j=0;
for $j (0 .. $#ignore_variables){
if ($ignore_variables[$j] eq $a_array[$i][0]) {
# Remove it from the array.
delete @a_array[$i];
}
}
}
However, this does not work properly. It removes the values of the object at [$i] but it does not actually remove the object as the array remains the same length and when printed out has a gap where the variable that was deleted was.
What am I doing wrong!
Cheers
Rob
Say I have an array @a_array which contain objects which are in turn arrays with 6 elements. I am trying to delete objects from that array whose first element equals an element of another array.
So far I have got this far (assume that @a_array and @ignore_variables has been declared and populated earlier).
my $i;
my $j;
for $i (0 .. $#a_array) {
$j=0;
for $j (0 .. $#ignore_variables){
if ($ignore_variables[$j] eq $a_array[$i][0]) {
# Remove it from the array.
delete @a_array[$i];
}
}
}
However, this does not work properly. It removes the values of the object at [$i] but it does not actually remove the object as the array remains the same length and when printed out has a gap where the variable that was deleted was.
What am I doing wrong!
Cheers
Rob