Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hello Everyone,

I have been working on a resource list for basic IRC programming in Perl. I noticed that there was no comprehensive tutorial node on perlmonks that discusses IRC programming, which is something I happened to have been reading about a lot lately. So I have written up a draft for the tutorials section or Q&A. I could use any advice you can offer involving content that needs to be added or sections that need to be modified. I definitely want to add more detail to the modules and server sections, and I was debating whether or not I should add some of my own code, as there is already plenty of fine example code elsewhere (which is linked from my node anyway). But if you see a reason for doing it over, I could maybe throw together a simple bot or something to illustrate some basic concepts.

It's not meant to be a full tutorial - there have been plenty written already. I just wanted to give people enough to enable them to learn more on their own. Here's what I've got so far. What would you change about it?

IRC Programming In Perl

Recently, I have started teaching myself how to write Perl programs for IRC (Internet Relay Chat). Here is a listing of a few resources that I have found helpful for learning to write my own IRC clients and servers in Perl.

Basic IRC Usage

If you haven't used IRC yet, it would probably be a good idea to play around with someone elses client, before you bother trying to write your own. IRC is a great tool for anyone learning to program Perl -- it is a great way to get real-time assistance, share your knowledge with other people, and just talk about interesting topics related to Perl. Check out the #Perl and #PerlHelp channels at, as well as the #Perl channel at

Please be sure to read the guidelines for the channels before you post to them...

For those of you who have not used IRC before, or who need a quick refresher, here is a listing of IRC Commands
IRC Commands.

Be sure you use it safely:
IRC Security

And here's a more detailed reference:
IRC Help Directory

IRC Clients that run Perl Scripts:

A great way to practice your Perl programming skills is to get a lightweight IRC client that is configured and operated via Perl scripts -- two such clients are sirc && irssi. And using a simple client is generally a more secure method of connecting to IRC than using a bloated (read: buggy & insecure) graphical client.

The irssi website has a large collection of scripts that you can look through to learn a bit about how they are written. You can find that collection below, as well as a link to a guide to writing Perl scripts for irsii:

Irssi Script Collection
irssi - Perl Scripting Reference
Irssi - Juerd's Site

There are many other clients to choose from as well -- a quick Google search for "irc client" will give you an idea of what's available to you.

Perl Modules For IRC

There are several modules on CPAN related to IRC. Here are some of those most commonly used:


As I mentioned earlier, although it might be useful to learn how to use Net::IRC (for things like modifying legacy code that uses it, etc), for the most part you will want to use POE::Component::IRC. It will make your life much easier.

Writing IRC Bots

Programming your own IRC bots is fun and is a great method for practicing all manner of programming skills -- especially linguistics and pattern matching. Analyzing the text from so many different people speaking, is quite a challenge. Plus it can be quite entertaining. But just be sure that your bot doesn't become a nuisance and interfere with other people's discussions or eat up the server's resources with needless chatter. Be respectful!

The following is a great beginner's resource for programming your own simple IRC bots using the Net::IRC module:

Programming IRC Bots In Perl

Note: You will probably want to start using the POE::Component::IRC module instead. However by learning the Net::IRC module, you might gain a deeper understanding of the POE::Component::IRC method, as you will have to build the event handling functionality in yourself.

The POE Cookbook has an excellent set of resources on programming IRC bots using the Perl Object Environment modules. They POE::Component modules' documentation is also excellent, so if you want to know about it, that will be the great place to start (here's that link again POE::Component::IRC)

There are also several CPAN bot modules. Check out these modules if you want to see some working bot code:


Running an IRC Server

It is quite easy to use Perl to write your own IRC server programs as well. For this, you will likely want to use the POE::Component::Server::IRC module. Like its client counterpart, the documentation is excellent:


To allow users to engage in meaningful conversation, you have to filter out a lot of garbage that floats in from the internet. This will help you with that:

IRC Operator's Guide

And of course, the usual rules still apply -- always be very cautious when allowing strangers to connect to services running on your server. If you are planning to start your own server, and you haven't read the security guide above, perhaps now is a good time to do so...

The IRC Protocol

And if you really want to get down. Here are some resources on the technical details behind the IRC protocols:

RFC 1459: Internet Relay Chat Protocol
RFC 2810: Internet Relay Chat: Architecture
RFC 2811: Internet Relay Chat: Channel Management
RFC 2812: Internet Relay Chat: Client Protocol
RFC 2813: Internet Relay Chat: Server Protocol

There is much more out there, but hopefully, once you have looked over the stuff above, you will know where to go from here.


In reply to RFC: Tutorial - IRC Programming In Perl by mmmmtmmmm

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and cookies bake in the oven...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (6)
    As of 2018-06-24 17:28 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.