Not really because of the way arrays work; %test[1] simply being an easy way to write %test_1 instead of %test being a formal collection
Probably the best you can do is a foreach function that takes the array name and a function to call on each member, internally using a while loop that starts searching and index 0 and continues until finding an element $= "". There's obvious disadvantages to that though