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. |