sub getlinks { my ($mech,...) = @_; ... code to get the webpage here ... my @links; for my $result ( $mech->links() ) { push @links, { title=>$result->name, text=>$result->text }; } return \@links; }