Subject: | Improve nslookup location on Windows |
When running Email::Valid on a Windows machine, the module would often fail in attempting to resolve a hostname. It could not find the 'nslookup' binary. The attached patch was the quickest and most obvious platform-independent approach that came to mind.
--- Valid.pm~ Fri Aug 2 11:30:44 2002
+++ Valid.pm Fri Aug 2 11:39:41 2002
@@ -7,12 +7,13 @@
use Carp;
use IO::File;
use Mail::Address;
+use File::Spec;
$VERSION = '0.14';
%AUTOLOAD = ( mxcheck => 1, fudge => 1, fqdn => 1, local_rules => 1 );
$NSLOOKUP_PAT = 'preference|serial|expire|mail\s+exchanger';
-@NSLOOKUP_PATHS = qw( /usr/bin /usr/sbin /bin );
+@NSLOOKUP_PATHS = File::Spec->path();
$DNS_Method = '';
sub new {
@@ -90,8 +92,11 @@
sub _find_nslookup {
my $self = shift;
+ my $ns = 'nslookup';
+ $ns .= '.exe' if $^O =~ /win32/i;
foreach my $path (@NSLOOKUP_PATHS) {
- return "$path/nslookup" if -x "$path/nslookup" and !-d _;
+ my $file = File::Spec->catfile( $path, $ns );
+ return $file if -x $file and !-d _;
}
return undef;
}