Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 12418
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: OLAF [...] cpan.org
Requestors: swc [...] iec.ch
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.49
Fixed in: (no value)



Subject: Unresolved calls in Net::DNS
I use Net::DNS in a library that sends emails from both inside and outside the firewall. To do this my library needs to know which SMTP server I'm supposed to use, which I discover by @smtp_list = mx('iec.ch'); This fails with the message Can't locate object method "query" via package MYPACKAGE at /usr/lib/perl5/site_perl/5.8.1/i586-linux-thread-multi/Net/DNS.pm line 312 Bug being reported is the unresolved reference in DNS.pm. Using the command: perl -c xxx, I get "syntax OK" on each piece of code (orignal program, my library, DNS.pm) until I get to .../Net/DNS/Resolver.pm at which point I get a number of errors. I've checked the @INC, and it looks OK so far as I can tell. Specifically, it includes the .../i586-linux-thread-multi/ directory in which Net and its sub-directories are found; from there on the Net::DNS, Net::DNS::etc references in the modules should be sufficient. I'm running perl v5.8.1 built for i586-linux-multi-thread with SuSE v9.0. (Full uname -a OS version is: Linux devweb-1 2.4.21-266-smp4G #1 SMP Fri Dec 10 17:06:22 UTC 2004 i686 i686 i386 GNU/Linux.) I upgraded/reinstalled Net::DNS to Net-DNS-0.49 (downloaded from cpan today), but that has not fixed the problem. Any thoughts? Files and/or output that could be helpful gladly provided on request. Thanks and regards, Sam Carmalt
[guest - Tue Apr 26 12:48:55 2005]: Show quoted text
> I use Net::DNS in a library that sends emails from both inside and > outside the firewall. To do this my library needs to know which SMTP > server I'm supposed to use, which I discover by > @smtp_list = mx('iec.ch'); > > This fails with the message > > Can't locate object method "query" via package MYPACKAGE at > /usr/lib/perl5/site_perl/5.8.1/i586-linux-thread-multi/Net/DNS.pm > line 312
I am puzzled... Does the most simple stripped down version generate the error? Try something like #!/usr/local/bin/perl -w # first test use Net::DNS; my @smtp_list=mx('iec.ch'); foreach my $mx ( @smtp_list) { $mx->print; } # end first test If it doesn't try this: #!/usr/local/bin/perl -w #test 2 use Net::DNS; my $res=Net::DNS::Resolver->new( debug => 1, ); $res->print; my @smtp_list=mx($res,'iec.ch'); foreach my $mx ( @smtp_list) { $mx->print; } #test 2
[scarmalt@iec.ch - Wed Apr 27 08:17:05 2005]: Show quoted text
> Thanks for your prompt reply. > > Your 2 tests work fine, but here is test3.pl together with the library it > calls; this still fails with the same error message > > Can't locate object method "query" via package "IECSMTPT" at > /usr/lib/perl5/site > _perl/5.8.1/i586-linux-thread-multi/Net/DNS.pm line 312. >
It seems to be an error in the way you try to create a new class. IECSMTPT does not inherit the methods from Net::DNS, you can fix that by using an ISA() and the the way you call the get_smtp_from_DNS method makes that the first argument is not the "dname" you expect but a reference to your newly created IECSMTPT object. You can fix that by shifting the "self". Fixed IECSMTP.pm is below. I close the ticket as this is not really a bug in Net::DNS.. Good luck though... package IECSMTPT; require 5.6.1; use strict; use Net::DNS; use vars qw(@ISA ); @ISA = qw(Net::DNS); sub new { my $class = shift; my $debugfile = shift; my $self = {}; bless $self,$class; $$self{debug} = $debugfile if $debugfile; return $self; } sub get_smtp_from_DNS { my $self=shift; my @temp; $_[0] = 'iec.ch' if !($_[0]); @temp = mx($_[0]); return @temp; } # end sub get_smtp_from_DNS 1;