James,

I appreciate your response. My familiarity w/ AnyEvent isn't too great and your response has helped greatly. What I ended up doing which I believe to look extremely ugly follows my comments. (again heavily modified)

To provide further details to hopefully paint a full picture .... I have two sources. One is from a command, and another is from a file. Both sources are pulled into an array and what I believe the below achieves is sending messages to the intersection of the arrays.

The below works with my limited testing and I appreciate the guidance thus far you've provided. I don't need further help unless of coarse you see something glaringly wrong, but until then, thanks James.

$muc->reg_cb( message => sub { my ( undef, undef, $msg ) = @_; my @connected_users = (); open my $fh, '-|', 'command_that_outputs_users' or die $!; my $w; $w = AnyEvent->io( fh => $fh, poll => 'r', cb => sub { my $user = $fh->getline; return if !defined($user); chomp($user); push(@connected_users, $user); if(eof($fh)){ close($fh); undef $w; open($fh, "< $file") or die $!; my $w2; $w2 = AnyEvent->io( fh => $fh, poll => 'r', cb => sub { my $user = $fh->getline; return if !defined($user); chomp($user); if($user ~~ @connected_users){ AnyEvent::XMPP::IM::Message->new( body => construct_body( $msg->body, $from ), to => "$user\@" . HOST, type => "chat", )->send($conn); close($fh); undef $w2; } } ); } } ); }, );

In reply to Re^2: AnyEvent weirdness w/ open() and/or ``'s by pprocacci
in thread AnyEvent weirdness w/ open() and/or ``'s by pprocacci

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.