in reply to Re^4: sysread and null characters
in thread sysread and null characters

The idea is that sysread is not returning the data, but a simple code that says "success" or "failure". The data is stored in your buffer ($digit).

my $i; while (sysread FH, $digit, 1) # same as: while (sysread(FH, $digit, 1) != 0) # (well, not quite, but close enough here.) { ++$i; # keep track of which digit we're looking at. # deal with the $digit you just got. printf "%04d %d\n", $i, $digit; }

Replies are listed 'Best First'.
Re^6: sysread and null characters
by ggg (Scribe) on Mar 24, 2005 at 18:50 UTC
    Thank you, Tanktalus! I really appreciate your time on this. It surprises me how much was left out of the perldoc description of this function.

    Again, thanks!

    ggg