Skip to content

Commit 368556a

Browse files
scottchiefbakerkhwilliamson
authored andcommitted
Add examples to documentation for sysread()
1 parent fecfa47 commit 368556a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pod/perlfunc.pod

+11
Original file line numberDiff line numberDiff line change
@@ -9572,6 +9572,17 @@ the string. A positive OFFSET greater than the length of SCALAR
95729572
results in the string being padded to the required size with C<"\0">
95739573
bytes before the result of the read is appended.
95749574

9575+
open(my $FH, "<", "input.txt") or die("Cannot open file: $!");
9576+
9577+
my $buf = "";
9578+
my $num = 0;
9579+
9580+
# Read up to 64 bytes
9581+
$num = sysread($FH, $buf, 64);
9582+
9583+
# Read up to 32 bytes into position 512 of $buf
9584+
$num = sysread($FH, $buf, 32, 512);
9585+
95759586
There is no syseof() function, which is ok, since
95769587
L<C<eof>|/eof FILEHANDLE> doesn't work well on device files (like ttys)
95779588
anyway. Use L<C<sysread>|/sysread FILEHANDLE,SCALAR,LENGTH,OFFSET> and

0 commit comments

Comments
 (0)