DBIx::DSN::Resolver - Resolve hostname within dsn string
use DBIx::DSN::Resolver; my $dsn = 'dbi:mysql:database=mytbl;host=myserver.example' my $resolver = DBIx::DSN::Resolver->new(); $dsn = $resolver->resolv($dsn); is $dsn, 'dbi:mysql:database=mytbl;host=10.0.9.41';
DBIx::DSN::Resolver parses dsn string and resolves hostname within dsn. This module allows customize the resolver function.
use the resolver argument
use Net::DNS::Lite qw(); use Socket; $Net::DNS::Lite::CACHE = Cache::LRU->new( size => 256, ); $Net::DNS::Lite::CACHE_TTL = 5; my $resolver = DBIx::DSN::Resolver->new( resolver => sub { Socket::inet_ntoa(Net::DNS::Lite::inet_aton(@_)) } ); $dsn = $resolver->resolv($dsn);
Default:
resolver => sub { Socket::inet_ntoa(Socket::inet_aton(@_)) }
Masahiro Nagano <kazeburo {at} gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DBIx::DSN::Resolver, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::DSN::Resolver
CPAN shell
perl -MCPAN -e shell install DBIx::DSN::Resolver
For more information on module installation, please visit the detailed CPAN module installation guide.