my $dns = DNS::Unbound->new();
my $query = $dns->resolve_async( 'example.com', 'A' );
# Ordinary ES6 Promise semantics:
$query->then( .. )->then( .. );
This object represents the result of an asynchronous DNS::Unbound query. It implements a standard promise interface and also provides a cancellation mechanism.
The promise resolves with a DNS::Unbound::Result instance. It rejects with a DNS::Unbound::X::ResolveError instance that describes the failure.
In addition to the then(), catch(), and finally() methods—see Promise::ES6 if you’re unsure of how to use those—this class provides:
Cancels an in-progress DNS query. Returns nothing.
NOTE: This will leave the promise unresolved.
To install DNS::Unbound, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.