title: How do I check if a user is authenticated with NickServ using POE::Component::IRC::State in Perl?
body: <p>I'm trying to test whether a user is registered on FreeNode. nick_info() doesn't seem to return information about this, so I want to use $irc->yield(whois => $nick); and then grab the irc_whois event's reply. The problem is that I want to wait until this event is fired, so I created a global variable $whois_result and wrote a sub like this:</p>
  
  <pre><code>sub whois {
      my $nick = $_[0];
      $whois_result = 0;
      $irc-&gt;yield(whois =&gt; $nick);
      while($whois_result == 0) { }
      return $whois_result;
  }
  </code></pre>
  
  <p>with the irc_whois handler looking like:</p>
  
  <pre><code>sub on_whois {
      $whois_result = $_[ARG0];
      print "DEBUG: irc_whois fired.\n";
  }
  </code></pre>
  
  <p>Unfortunately, the event can't fire while the loop is running so this hangs. I'm sure there's a better way to do this, but I'm not familiar enough with this kind of programming to know. Any help would be greatly appreciated. </p>