AnyEvent-DNS-EtcHosts

 view release on metacpan or  search on metacpan

lib/AnyEvent/DNS/EtcHosts.pm  view on Meta::CPAN

=head2 use AnyEvent::DNS::EtcHosts %args

=for markdown ```perl

use AnyEvent::DNS::EtcHosts server => '8.8.8.8';

$ perl -MAnyEvent::DNS::EtcHosts script.pl

=for markdown ```

Enables this module globally. Additional arguments will be passed to
L<AnyEvent::DNS> constructor.

=cut

sub import {
    my ($class, %args) = @_;
    $GUARD = $class->register(%args);
}

=head2 no AnyEvent::DNS::EtcHosts

Disables this module globally.

=cut

sub unimport {
    my ($class) = @_;
    undef $GUARD;
}

=head1 METHODS

lib/AnyEvent/DNS/EtcHosts.pm  view on Meta::CPAN


    undef $guard;

=for markdown ```

Enables this module in lexical scope. The module will be disabled out of
scope. Additional arguments will be passed to L<AnyEvent::DNS> constructor.

If you want to use AnyEvent::DNS::EtcHosts in lexical scope only, you should
use C<require> rather than C<use> keyword, because C<import> method enables
AnyEvent::DNS::EtcHosts globally.

=cut

sub register {
    my ($class, %args) = @_;

    my $old_resolver = $AnyEvent::DNS::RESOLVER;

    $AnyEvent::DNS::RESOLVER = do {
        my $resolver = AnyEvent::DNS::EtcHosts->new(



( run in 0.432 second using v1.01-cache-2.11-cpan-49f99fa48dc )