in reply to Re: Jabber MUC bot channel list problem.
in thread Jabber MUC bot channel list problem.

Hi,

Thank you for your reply. The one thing I cannot imagine a bit is how do I use this hash to store users. How do I add user to that hash ? If $jid is a key, then each key ($jid) must have a value. What is that value ? Anything ? Also I created some test script which checks your way of thinking.

Please take a look:

#!/usr/bin/perl use Data::Dumper; my %roster; @jid= qw |test1 test2 test3 test4|; foreach $jid (@jid) { $roster{$jid} = "0"; } foreach $jid (@jid) { print Dumper ($roster{$jid}); } @keys = keys %roster; print "Keys: @keys\n"; $jid = "test1"; if ($roster{$jid}) { print "something"; }
Why the last if doesn't print "something" if the key exists ?

Thank you for your help

Regards.

Replies are listed 'Best First'.
Re^3: Jabber MUC bot channel list problem.
by oxone (Friar) on May 25, 2011 at 21:59 UTC
    Any true value is fine for your hash, but unfortunately you've chosen 0 which isn't true. Use 1 instead, and the last test will then work as you want it to.
      Hi,

      This is working perfect. Thank you very much for your help. I can continue my work now:).

      Once again, thank you.

      Regards.