Thanx for effort liz :)

This is a sample of code that exists. i've left all the use module::module; for you to see what i use in the entire bot.

This bot just sends TEST TEST to a user who does .help

With threaded perl it works good. starts a process then it exits it when done but loads alot of memory. With forks it works but it doesnt end the process, the extra bot.pl is still there when ps -aux | grep bot.pl

bot.pl
#!/usr/bin/perl -w use Net::IRC; use strict; use HTTP::Response; use HTML::LinkExtor; use URI::URL; use DBI; use Data::Dumper; use File::Basename; use File::Path; use vars qw($search $text $ftp); use Net::FTP; use Config::IniFiles; use Number::Format; use LWP::UserAgent; use HTTP::Request; #use Thread; use FileHandle; use Time::HiRes qw(usleep ualarm gettimeofday tv_interval); use Date::Calc qw(:all); use Net::Cmd; use forks; my $ircserver = '127.0.0.1'; + my $ircport = '7777'; + our $ircchannel = '#test'; + my $ircbotname = 'labrat'; + my $joingreet = 'hello fellas'; + my $nickgreet = 'welcome '; my $ircname = 'labrat'; + my $username = 'labrat'; + my $localip = '192.168.0.1'; + my $pid = $$; our $bold = chr(2); print "Preparing to load required files!!\n"; ### MODULES ### require "help_module.pl"; print "Required Files loaded OK!!\n"; sub ircinfo { our $irc = new Net::IRC; our $conn = $irc->newconn( Server => $ircserver, Port => $ircport, Nick => $ircbotname, Ircname => $ircname, LocalAddr => $localip, Password => 'fucknuts.', Username => $username ); $conn->{channel} = $ircchannel; $conn->add_handler('join', \&on_join); $conn->add_handler('part', \&on_part); $conn->add_handler('public', \&on_public); $conn->add_handler('376', \&on_connect); $conn->add_global_handler('disconnect', \&reconnect); $conn->add_global_handler(433, \&on_nick_taken); $irc->start(); } sub reconnect { system("./bot.pl &"); system("kill -9 $pid"); } sub default { my ($conn, $event) = @_; print Dumper($event); } sub on_connect { my $conn = shift; $conn->join($conn->{channel}); $conn->privmsg($conn->{channel}, $joingreet); $conn->{connected} = 1; $conn->add_global_handler(433, \&on_nick_taken); } sub on_nick_taken { my ($self) = shift; $self->nick(substr($self->nick, -1) . substr($self->nick, 0, 8)); } sub on_join { my ($conn, $event) = @_; my $nick = $event->{nick}; my $host = $event->{host}; $conn->privmsg($conn->{channel}, "$nickgreet," . $bold . " $nick" +. $bold ); } sub on_part { my ($conn, $event) = @_; my $nick = $event->{nick}; $conn->privmsg($conn->{channel}, "Goodbye, $nick!"); } sub on_public { my ($conn, $event) = @_; my $text = $event->{args}[0]; if (lc substr($text,0,5) eq ".help") { my $info = substr($text,6); my $helpthr = threads->new(\&help, "$event->{nick}"); $helpthr->detach; } } print "Starting Bot!!\n"; ircinfo();
This is the help_module.pl
sub help { my $nick = shift; $conn->privmsg($nick, $bold . "TEST " . $bold . "TEST"); last(); # Here i've tried with last; exit(); return; } 1;
I'm really stuck on this :/ I dont have a singel clue. Might be my irc module thas poorly written to. Hope you get something out of it :)

/Chris

In reply to Re: Re: Re: Re: Re: Re: Threads Problem! by Anonymous Monk
in thread Threads Problem! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.