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

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: About Broadcasting
by Corion (Patriarch) on Nov 05, 2007 at 09:03 UTC

    You don't tell us how it does not run for you. From a cursory inspection, I guess that one of the errors is on the following line:

    sysread(STDIN,$data,1024)||exit 0;

    I suggest you change that line to:

    if (! my $res = sysread(STDIN,$data,1024)) { if (defined $res) { print "End of user input. Thanks for playing.\n"; exit 0; } else { die "Couldn't read from input: $!"; }; };

    But as it's inconvenient for me to duplicate your situation or to check what sysread returns when there is no input to be read from STDIN, maybe you care to tell us more about how your code does not work for you. Maybe Perl tells you something about it?

      I have changed this code but it warn: "Can't modify not in scalar assigment at   if (! my $res=sysread(STDIN,$data,1024)) zzz.... I'm very confuse,i don't know why and how

        Ah, that's a typo/thinko by me. Moving the expression part before the if statement works, but you could have tried out that yourself.

        ... my $res = sysread(STDIN,$data,1024); if (! $res) { if (defined $res) { print "End of user input. Thanks for playing.\n"; exit 0; } else { die "Couldn't read from input: $!"; }; }; ...

        Let me remind you that you still haven't told us at all how the program is failing for you and at what step. Without that knowledge, we cannot help you much and all we can do is guess based on cursory inspection of your code.

        A reply falls below the community's threshold of quality. You may see it by logging in.
Re: About Broadcasting
by Anonymous Monk on Nov 05, 2007 at 09:01 UTC
    What errors/warnings does it make?
    A reply falls below the community's threshold of quality. You may see it by logging in.