In general when using POE (or another event loop) you're not going to be writing a while loop like that. It's a different mindset where you've got to turn your traditional imperative thinking sort of inside out. Rather than saying "Do X, then do Y, then do Z, then exit" instead you set up handlers you want called when certain things happen (network connections are received, data comes in on a socket, a filehandle becomes readable, . . .), wire things up (in POE you'd do this (say) by making a POE::Session instance mapping with inline_states from event names to your subs), and then you start the event loop and let it take over. When something you've expressed interest happens, the event loop cals your code which does its thing and then returns control back to the event loop.

Without a bit more detail what exactly your fetch_data is doing it's going to be hard to give a more specific example how to hook things up (or if you're lucky, point you at an existing module), but there's several samples in the POE distribution which might help steer you the right way; e.g. examples/queue.perl. There's also the POE Cookbook which has a good smattering of samples as well.

Edit: wording.

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re: Need help in getting started with POE by Fletch
in thread Need help in getting started with POE by smarthacker67

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.