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."); } #### sub on_connect { my $conn = shift; $conn->join($conn->{channel}); $conn->{connected} = 1; } #### sub on_disconnect { sleep 30; # Waits for 30 seconds do_runlog(4,""); # Logs that it lost the connection start_it(); # Start over }