in reply to why does array return the hash value?

Even without exactly knowing what the XMLP module does, one may safely assume that the GetElementsByName method returns a list of objects.

If you iterate over them in a for loop, $variable will get set to the next object and the Getelementbyvalue will know what to do with it.

However if you sort the list of objects, poor sort has no clue what to do with the object, so by default it will stringify the object, indeed giving you something like HASH(0x67890809) as most objects are implemented as references to a hash. Unfortunately, stringifying an object actually destroys the objectness of it, or rather the result of stringifying an object is no longer an object.

Does it mean that one cannot sort objects? Of course not, but a naive sort is not going to be able to do it. At the very least you will have to find out on basis of which attribute of the object you will have to do the sort and then write a subroutine which you can give to sort to use.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: why does array return the hash value?
by noobnoob (Initiate) on Apr 11, 2010 at 15:44 UTC
    Thanks for the explanation! it helps on my understanding!