in reply to Re: Net::Jabber: Receiving answers without callbacks
in thread Net::Jabber: Receiving answers without callbacks

On the chatterbox somebody (sorry for forgetting
who did help me) suggested me to use closures.
I did it and it worked fine. The example
code follows below. Thanks everyone for the
inspiration!
sub gpib_write { my ($self, $command) = @_; print "Sending ->$command<- to gpib ud=$self->{ud}.\n" if ($debug); my $message = "GPIB|write|$self->{ud}|$command"; # Send message to gpib server $self->{conn}->MessageSend(to=>'gpibserver@xxx.yyy.zzz', subject=>"", type=>"groupchat", body=>$message, thread=>"", priority=>10); print " Message sent: ->$message<-\n" if ($debug); # Acknowledge comes through callback my $answer; $self->{conn}->SetCallBacks( message=>sub{ my $sid = shift; my $message = shift; my $body = $message->GetBody(); print " Acknowledge received: ->$body<-\n" if +($debug); $answer = $body; } ); return $answer; }