My output is:my $result; while (select my $rd = $rin, undef, undef, 60) { my $bytes = sysread *CMD, substr($result, -1), 4096; last if 1 > $bytes; } ... print "I am finished with my task. My results are: \n"; print $result."\n";
What happened to all of the other lines from the ping (should be 15 result lines)? I would expect it to be:I am finished with my task. My result are: Pinging google.com [216.239.37.99] with 32 bytes of data: Reply from 216.239.37.99:bytes=32 time=36ms TTL=244 Ping statistics for 216.239.37.99: Packets: Sent = 15, Received = 15, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 36ms, Maximum = 37ms, Average = 36ms
What happens that makes the $result apparently overwrite the output of the *CMD? I would still want to output the live results and set the variable, so would it be best to use the concatenation? I can't print $result in the loop, since that would contain all of the output, not just that loop's progress.I am finished with my task. My result are: Pinging google.com [216.239.37.99] with 32 bytes of data: Reply from 216.239.37.99: bytes=32 time=37ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=36ms TTL=244 Reply from 216.239.37.99: bytes=32 time=37ms TTL=244 Reply from 216.239.37.99: bytes=32 time=37ms TTL=244 Reply from 216.239.37.99: bytes=32 time=37ms TTL=244 Ping statistics for 216.239.37.99: Packets: Sent = 15, Received = 15, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 36ms, Maximum = 37ms, Average = 36ms
In reply to Re^4: SIGINT and system calls
by Anonymous Monk
in thread SIGINT and system calls
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |