this has me flumoxxed, I set up two arrays, call and dat.
there is one exclusive element in both, and 4 inclusive, but when I delete from one of the arrays, the exclusive element magically moves to the other array. Is this a bug in awk ?
BEGIN {
# call[1] is exlusive to call array
call[1]=10
call[2]=20
call[3]=30
call[4]=60
call[5]=70
dat[2]=20
dat[3]=30
dat[4]=60
dat[5]=70
#dat6 is exclusive to dat array
dat[6]=80
print "elements in dat array"
for (i in dat)
print i,dat
print "where the values don't match"
for (i in call) {
if (call==dat) {
delete call
delete dat
print "got match , deleting element " i
}
}
print "in call array not in dat array"
for (i in call)
{
print i, call
delete call
print "deleted element from call array" i
}
print "in dat array not in call array"
for (i in dat)
print i,dat
}
OUTPUT is
elements in dat array
2 20
3 30
4 60
5 70
6 80
where the values don't match
got match , deleting element 2
got match , deleting element 3
got match , deleting element 4
got match , deleting element 5
in call array not in dat array
1 10
deleted element from call array1
in dat array not in call array
6 80
1
The problem lies with the one at the end(it looks like the element has moved from one array to another, but without the value). If I explicitly delete dat[1], it works fine, but I shouldn't have to..
please help
there is one exclusive element in both, and 4 inclusive, but when I delete from one of the arrays, the exclusive element magically moves to the other array. Is this a bug in awk ?
BEGIN {
# call[1] is exlusive to call array
call[1]=10
call[2]=20
call[3]=30
call[4]=60
call[5]=70
dat[2]=20
dat[3]=30
dat[4]=60
dat[5]=70
#dat6 is exclusive to dat array
dat[6]=80
print "elements in dat array"
for (i in dat)
print i,dat
print "where the values don't match"
for (i in call) {
if (call==dat) {
delete call
delete dat
print "got match , deleting element " i
}
}
print "in call array not in dat array"
for (i in call)
{
print i, call
delete call
print "deleted element from call array" i
}
print "in dat array not in call array"
for (i in dat)
print i,dat
}
OUTPUT is
elements in dat array
2 20
3 30
4 60
5 70
6 80
where the values don't match
got match , deleting element 2
got match , deleting element 3
got match , deleting element 4
got match , deleting element 5
in call array not in dat array
1 10
deleted element from call array1
in dat array not in call array
6 80
1
The problem lies with the one at the end(it looks like the element has moved from one array to another, but without the value). If I explicitly delete dat[1], it works fine, but I shouldn't have to..
please help