sub start_it { my $irc = new Net::IRC; my $conn = $irc->newconn ( Server => shift || $server, Port => shift || $port, Nick => $botnick, Password => $pass, Ircname => 'My IRC Bot', Username => $botnick ); $conn->{channel} = shift || '#'.$canal; $conn->add_handler('376', \&on_connect); $conn->add_handler('quit', \&on_quit); # Lots of other handlers here, and below the one who should do what I want: $conn->add_handler('disconnect', \&on_disconnect); $irc->start() || die("Impossible to start."); }