I haven't delved into this area of Perl, but heaps are meant for dynamic allocation of individual records, rather than arrays of records. So it seems as a pure guess, you should either allocate each record individually in a linked list or use the stack to make it function like an array.