Folks,

Ive got code working on 5.6.1 on Linux that doesnt on ActivePerl build 
631 on win2000

My best guess (WAG at this point) is some interference between IO::Select,
which is the core of a messaging hub, and STDIN, which Im trying to use 
to annotate
the message logs as theyre written.

problem arises when user gives option -anote, which ends up in %$opt 
passed into Log::new(),
causing ctor to open an IO::Handle on STDIN.  This appears to break the 
IO::Select operations,
which would otherwize accept new connections at the hub.

Ill try to reduce to a test-case, but heres a quick look at the code 
fragment which (when run)
causes the problem (only on windows)




package Log;

.....

our $new_anote = 1;  # 0,1, both work on unix, neither on win

##############

# list of tags accepted by new, build rex from it
$Log::tags = join '|', qw(log play verbose load outdir check logmsgs anote);

sub new {
    my ($class, $opt) = @_;

    my %args = %$opt;
    # delete option tags which dont match approved list
    delete @args{ grep !/$Log::tags/, keys %args };

    # remaining are legal, add each to object
    my $self = bless {%args}, $class;

    if ($self->{anote} and $new_anote) {
      my $io = new IO::Handle;
      $io->fdopen(*STDIN, "r");
      $io->blocking(0);
      $self->{anote} = $io;
    }
......
}


sub snap {
    my ($self, $tag, $msg) = @_;

    print "snapping $tag\n";

    if ($self->{anote}) {
    # handle annotations on stdin b4 logging latest msg
    (my $atag=$tag) =~ s/[HC]$//;

    if (!$new_anote) {
        if (my $found = select(my $bits=$cbits,undef,undef,0)) {
        # got annotation, read it
        my $buf;
        sysread(STDIN, $buf, 10000);
        chomp $buf;
        print "you said: $buf, $atag\n";
        $logfh->print("${atag}A: <$buf> Ascii\n");
        }
    } else {
        foreach ($self->{anote}->getlines) {
        print "you said: $_, $atag\n";
        $logfh->print("${atag}A: <$_> Ascii\n");
        }
    }
    }
..........

 }





_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to