Hello monks-

I am using a IO::Select object to manage multiple network connections. Currenty I am having trouble removing a socket from my select. If I run the following code:

#!/usr/bin/perl use IO::Select; use Data::Dumper; $sel = IO::Select->new(STDIN, STDOUT, STDERR); @hand = $sel->handles(); print Dumper \@hand; $sel->remove(STDIN); @hand = $sel->handles(); print Dumper \@hand;
I get the following expected output:
$VAR1 = [ 'STDIN', 'STDOUT', 'STDERR' ]; $VAR1 = [ 'STDOUT', 'STDERR' ];
In my system I have a little method called remove socket.
sub removeSocket { my ($self, $socket) = @_; my $select = $self->{'select'}; print STDERR 'dumping: ',Dumper $socket; my @handles = $select->handles(); print STDERR '>>before: ',Dumper \@handles; my $retVal = $select->remove($socket); print STDERR $retVal, $/; my @handles2 = $select->handles(); print STDERR '>>after: ',Dumper \@handles2; }
Which gives the following, and in my mind very confusing, output when run in the larger system:
dumping: $VAR1 = \bless( \*Symbol::GEN1, 'IO::Socket::INET' ); >>before: $VAR1 = [ bless( \*Symbol::GEN0, 'IO::Socket::INET' ), bless( \*Symbol::GEN1, 'IO::Socket::INET' ) ]; 0 >>after: $VAR1 = [ bless( \*Symbol::GEN0, 'IO::Socket::INET' ), bless( \*Symbol::GEN1, 'IO::Socket::INET' ) ];
Any thoughts? Thanks in advance. (btw although I have been a perl programmer for 5 years I have not done a lot of socket programming, and also have not spent any time on perlmonks)

In reply to IO::Select behavior by chanson

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.