I have been tasked with converting all of the network utilities I've written over the years in MUMPS into a language likely to be known by more people. Most of it will be converted to Perl. So far the conversion hasn't presented to many difficulties but there is one construct for which I have not been able to derive a close equivalent. To wit:
MUMPS arrays use alphanumeric indicies with a defined collating order. Numeric subscripts collate first, in numeric order, followed by string subscripts in ASCII order. Thus, an array with the following indicies would collate in this order: -2,-1,0,1,2,9,100,101.5,A,E,H,a,c,z etc. MUMPS arrays are also sparse arrays and are multidimensional. However, for this question, it is okay to assume an array with only one dimension. The MUMPS language provides a function, called $ORDER, which takes an argument and returns the next index that exists in the array that would come after the supplied argument (a 2nd argument can be used to cause the function to return the previous index instead of the next index). For example, given an array with the index values given above, if I asked for the next index after 0, I would get 1; the next index after 50 would return 100; the next index after "Z" would return "a"; etc. My question: is there any way to approach similar functionality in Perl? Any non-numeric arrays in my code are being converted to Perl hashes. I can retrieve the value of a specific key, and I can use a for loop to go through every key/value pair but, is there any way of doing something similar to $ORDER without have to scan the entire hash? Also, is there any defined order in which a hash is stored? Thanks for any help any of you can provide. Mark Berryman