bobo has asked for the wisdom of the Perl Monks concerning the following question:
i have @open array which I tied with Tie::array...
i fill that array with objects, but i don't think that's the problem...
anyway...
before spliceing i have in @open objects with ids {102001, 103002, 100001, 101002, 103001, 99000, 102000, 103003, 99001, 100002} (array is sorted by other object data).
after
for my $i(0..$#open){ if ($open[$i]->id==$node->id){ my $bla = splice @open, $i, 1; print "i=$i\t"."id=".$bla->id."\n"; last; } }
perl writes out "i=6 id==102000" (which is correct id i was looking for and correct index of object with that id)
and i get in @open object with ids {102001, 103002, 100001, 101002, 103001, 99000, 102000, 103003, 103003}
what went wrong? :(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tie::array and splice
by almut (Canon) on Apr 01, 2010 at 09:51 UTC | |
|
Re: Tie::array and splice
by jethro (Monsignor) on Apr 01, 2010 at 08:38 UTC | |
by bobo (Novice) on Apr 01, 2010 at 09:23 UTC | |
by almut (Canon) on Apr 01, 2010 at 10:03 UTC |