Net-DNS-RR-SRV-Helper
view release on metacpan or search on metacpan
lib/Net/DNS/RR/SRV/Helper.pm view on Meta::CPAN
package Net::DNS::RR::SRV::Helper;
use warnings;
use strict;
use Exporter;
use Sort::Naturally;
our @ISA = qw(Exporter);
our @EXPORT = qw(SRVorder);
our @EXPORT_OK = qw(SRVorder);
our %EXPORT_TAGS = (DEFAULT => [qw(SRVorder)]);
=head1 NAME
Net::DNS::RR::SRV::Helper - Orders SRV records by priority and weight for Net::DNS.
=head1 VERSION
Version 0.0.0
=cut
our $VERSION = '0.0.0';
=head1 SYNOPSIS
use Net::DNS;
use Net::DNS::RR::SRV::Helper;
use Data::Dumper;
my $query=$res->search("_ldap._tcp.foo.bar", SRV);
my @answers=$query->answer;
my @ordered=SRVorder(\@answers);
if(!defined( $ordered[0] )){
print "No usable records were found.\n";
}else{
print Dumper(\@ordered);
}
=head1 EXPORT
SRVorder
=head1 FUNCTIONS
=head2 SRVorder
This takes the returned answer array containing Net::DNS::RR::SRV
objects and processes them into a new easy to use array of hashes
ordered by priority and weight.
One item is taken and that is the array returned from the answers method.
Upon a error or no records being present, undef is returned.
=cut
sub SRVorder{
my @records=@{$_[0]};
if (!defined($records[0])) {
return undef;
}
( run in 1.259 second using v1.01-cache-2.11-cpan-524268b4103 )