Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Very Basic Perl Question about IRC

by Tanktalus (Canon)
on Nov 06, 2012 at 01:48 UTC ( #1002409=note: print w/ replies, xml ) Need Help??


in reply to Very Basic Perl Question about Sockets .. and IRC

There are a few approaches available here. The most obvious might be to use threads - one thread that would read from the socket (blocking), a second thread to write to the socket (blocks on the input queue used to feed it stuff to send), and a third to read from stdin (perhaps using Term::ReadLine). I'm not sure if that middle thread is quite needed, though it would handle race conditions between the first and last threads for sending stuff to the IRC server.

Personally, I do this basic type of thing with a single thread using event-based code, usually AnyEvent/Coro, though some will swear by POE. And, with a new enough Term::ReadLine, you can integrate it with Coro fairly well, or other event loops not quite so well, but still passably if done with Term::ReadLine being your main event loop (see Term::ReadLine::Event for example code), though there's always the issue of spitting stuff to the screen (input from IRC server) while waiting at a prompt.

That's for "this basic type of thing." For this specific type of thing (IRC), I use Xchat and perl plugins to Xchat.


Comment on Re: Very Basic Perl Question about IRC
Replies are listed 'Best First'.
Re^2: Very Basic Perl Question about IRC
by Contraversy (Initiate) on Nov 06, 2012 at 02:06 UTC
    Thank you so much, more than enough info here to do what I need!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002409]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (18)
As of 2015-07-31 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls