Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

infinite while loop in POE::Component::IRC

by Mik0r (Novice)
on Jun 09, 2010 at 01:47 UTC ( #843784=perlquestion: print w/replies, xml ) Need Help??

Mik0r has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am using POE::Component::IRC for my IRC bot. I have written a script using File::Tail to print a log file in real-time. The script works fine as a separate script but when I add this script into my IRC bot it causes it to lock up and ping out. I'm assuming It's a buffer issue. I've tried setting $| = 1; and I tried changing the while loop to an if loop like in the POE cookbook so it looked like this:

sub outputlog { if ($switch == 1) { sleep 3; print "test"; outputlog->(); } }

But no matter what I try even to do a basic loop like above it causes the bot to freeze and ping out. Anyone have any insight on how to make an infinite loop unbuffered in POE?

Replies are listed 'Best First'.
Re: infinite while loop in POE::Component::IRC
by choroba (Archbishop) on Jun 09, 2010 at 09:50 UTC
    Your sub can be simplified to
    sub outputlog { outputlog() }
    (once $switch is true). This is an infinite loop, indeed, but with no relation to buffering.
Re: infinite while loop in POE::Component::IRC
by bingos (Vicar) on Jun 10, 2010 at 21:03 UTC

    POE is cooperative multitasking, which means that any part of the program that blocks will halt the whole program. In your case your infinite loop.

    I wrote a plugin to handle tailing a file to IRC called POE::Component::IRC::Plugin::FollowTail, it has been shipped in the POE-Component-IRC distribution since version 5.48 and uses POE::Wheel::FollowTail, to non-blockingly tail a file

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://843784]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-05-16 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (62 votes). Check out past polls.

    Notices?