Example of how to access get_links() data

I’m trying to write a script in Perl to export tickets from RT (and other systems), but I cannot work out how to access the data sent back by the get_links API call. I can use foreach() to retrieve the “RefersTo” and “ReferredToBy” parts but I cannot retrieve each of the links in each section.

My library is v0.45 and the two RT instances are 4.0.23 and 4.2.10.

Any recommendations or sample code?

Over the weekend I managed to work out the correct way to do this, after much reading of the source code and working out how arrays of hashes work. Here is the solution for anyone else that has this problem:

# Retrieve the ticket links from RT
$links = $rt->get_links ( id => $id );

# $links is a hash of arrays.

# Get any 'refers to' tickets numbers.
foreach $link ( @{$links->{'RefersTo'} }) {
        print "Refers-to link: " . $link->{'id'} . "\n";

# Get any 'referred to by' tickets numbers.
foreach $link ( @{$links->{'ReferredToBy'} }) {
        print "Referred_to_by link: " . $link->{'id'} . "\n";