Skip to content

Commit

Permalink
Add examples in read()
Browse files Browse the repository at this point in the history
  • Loading branch information
scottchiefbaker committed Jan 29, 2025
1 parent 71404d3 commit b2a98ae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pod/perlfunc.pod
Original file line number Diff line number Diff line change
Expand Up @@ -6686,6 +6686,14 @@ X<read> X<file, read>

=for Pod::Functions fixed-length buffered input from a filehandle

open(my $FH, "<", "input.txt") or die("Cannot open file");

my $buf = "";
my $num = 0;

$num = read($FH, $buf, 32); # Read the first 32 bytes of file
$num = read($FH, $buf, 16, 1024); # Read 16 bytes at position 1024

Attempts to read LENGTH I<characters> of data into variable SCALAR
from the specified FILEHANDLE. Returns the number of characters
actually read, C<0> at end of file, or undef if there was an error (in
Expand Down

0 comments on commit b2a98ae

Please sign in to comment.