The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/opt/perl/bin/perl
use strict;
use utf8;
use AnyEvent::Impl::Tk;
use AnyEvent;
use AnyEvent::XMPP::Client;

my $j = AnyEvent->condvar;
my $cl = AnyEvent::XMPP::Client->new (debug => 1);
$cl->add_account ('net_xmpp2@jabber.org', 'test');
$cl->reg_cb (
   session_ready => sub {
      my ($cl, $acc) = @_;
      print "session ready\n";
      $cl->send_message (
         "Hi! I'm too lazy to adjust examples!" => 'elmex@jabber.org', undef, 'chat'
      );
   },
   disconnect => sub {
      my ($cl, $acc, $h, $p, $reas) = @_;
      print "disconnect ($h:$p): $reas\n";
      $j->broadcast;
   },
   error => sub {
      my ($cl, $acc, $err) = @_;
      print "ERROR: " . $err->string . "\n";
   },
   message => sub {
      my ($cl, $acc, $msg) = @_;
      print "message from: " . $msg->from . ": " . $msg->any_body . "\n";
   }
);
$cl->start;
$j->wait;