in reply to [untitled node, ID 165538]
First here is some debugging code:
#!/usr/bin/perl -w use CGI; use CGI::Carp qw(fatalsToBrowser); use lib '/home/samn/cgi-bin/lib/'; use Net::AIM; use Data::Dumper; # preove that the module is listening ;-) # print "Content-type: text/html\n\nNet::AIM Version: ", $Net::AIM::VE +RSION; # exit; $aim = new Net::AIM; $conn = $aim->newconn(Screenname => 'Robotskull', Password => 'passwor +d'); # check our objects using Data::Dumper (need to escape HTML, pre tag e +tc) #$q = new CGI; #my $data = Dumper ($aim , $conn); #$data = $q->escapeHTML($data); #print $q->header, "<pre>$data</pre>"; #exit; $conn->set_handler('im_in',\&on_im); $aim->start; sub on_im { my ($self, $event) = @_; my ($nick) = $event->from; print $event->dump; my @args = $event->args; $self->send_im($nick, "Hi $nick. You said: $args[2]"); }
Note as I suggested you only need to use lib '/home/samn/cgi-bin/lib/' although you can be more explicit you don't need to be as @INC contains . /lib/site_perl/5.6.0 and /site/lib/site_perl/5.6.0 and will check all those paths. See my A Guide to Installing Modules tutorial for details.
Uncomment the debugging code one bit at a time. The first bit proves you have the module as it can find the $VERSION but as I explained we know that because the error message comes from the module.
Next uncomment the Dumper part
Note that while $aim looks like an object $conn does not. It looks like a 1 to me. Hmmm methinks error in the newconn() method.
Go to the newconn() sub in Net::AIM
Note that instead of returning $conn it returns 1. This is a bug in the software and I have no idea how the author could have failed to notice because the module will not work until you fix it.
Patch the sub like this:
sub newconn { my $self = shift; my $conn = $self->{_conn} = Net::AIM::Connection->new($self, @_); return undef if $conn->error; # return 1; # bzzt, we need to return the object return $conn; }
GOK if the rest of it works, it now hangs for me with no errors which I guess is good given the lack of code. Note that contrary to the advice above Net::AIM uses Net::AIM::Connection so you don't need to access it directly as suggested.
Finally email the author with the patch being as rude as you feel like (depends if the rest of it works :-)
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
|---|