Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Array Cleaningby Necos (Friar) |
on May 02, 2003 at 20:35 UTC ( [id://255159]=note: print w/replies, xml ) | Need Help?? |
There is one more way to deal with the splicing problem: run through the array backwards. It sounds wierd, but it does work. If you build up a list of the indexes that you want to splice out, process it in reverse (using pop), and then splice, the indices won't change (because the array is shrinking from the end), and everything is fine. I just so happened to get bitten by something similar. Consider the following (untested) snippet: I actually used something like this in a module I'm writing. I hope it's of some use to you. YMMV. Theodore Charles III Network Administrator Los Angeles Senior High email->secon_kun@hotmail.com perl -e "map{print++$_}split//,Mdbnr;"
In Section
Seekers of Perl Wisdom
|
|