Hi,
First off, have you looked at
Net::IRC,
Bot::BasicBot or
Bot::Pluggable? They may save you some time, unless you're determined to reinvent the wheel. If you are, see if you can build a whole bike for us. :-)
I'm not sure how your code looks outside of your posting, but may I suggest you use a set of functions that is given to easily readable and reuseable code? I happen to like the following type of method myself:
# Untested code for demonstation purposes only
while($command = <IRC>) {
last if /please leave, $botname/;
bot_command($command);
}
sub bot_command {
my $command = shift(@_);
join_channel($command) if ($command =~ /join/);
part_channel($command) if ($command =~ /part/);
msg_user($command) if ($command =~ /msg/);
....
default($command);
}
sub join_channel {
...
}
sub part_channel {
...
}
I'm not saying this is the best way to do it, but it's worked for me when I need to multiplex between a number of different choices. It keeps my code bits isolated from each other, and it's easy for other people to read.
This being said, I'm still trying to figure out how a dispatch table works -- if you can figure that one out, that might be a good bet for you.
I should probally attempt to answer your question, eh? :-)
You're opening the file as
open(REMOVE, ">project.pjt")
Which is output only, but you're trying to read from it via
$remove = <REMOVE>;
If you have
use warnings turned on, when you try this you should get an error like:
Filehandle FILE opened only for output at C:\file.pl line 7.
To open a file for reading AND write, use:
open(REMOVE, "+>project.pjt")
but this will clober your file, removing any contents before you can read from it. Use
open(REMOVE, "+>>project.pjt")
if you want to read and write (append) to the file without zapping the contents everytime. See also
the perl Open() tutorial.
Hope this helps (and that I got it right),
ibanix
$ echo '$0 & $0 &' > foo; chmod a+x foo; foo;
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.