Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL read Function
Syntax
read FILEHANDLE, SCALAR, LENGTH, OFFSET
read FILEHANDLE, SCALAR, LENGTH
|
Definition and Usage
Reads, or attempts to read, LENGTH number of bytes from the file associated with FILEHANDLE into BUFFER. If an offset is specified, the bytes that are read are placed into the buffer starting at the specified offset.
Return Value
Example
Try out following example:
#!/usr/bin/perl -w
my($buffer) = "";
open(FILE, "/etc/services") or
die("Error reading file, stopped");
while(read(FILE, $buffer, 100) )
{
print("$buffer\n");
}
close(FILE);
|
It will produce following result. This is just sanpshot of the result
kerberos_master 751/udp # Kerberos authentication
kerberos_master 751/tcp # Kerberos authenti
cation
passwd_server 752/udp # Kerberos passwd server
| |
|

|
|
|