Input/Output
The Read Function
- The read() function reads a specified number of bytes
from a file handle and stores the data in a scalar variable
- The return value is the number of bytes actually read
$count = read( FILEHANDLE, SCALAR, LENGTH );
- For example, here's a very simple "cp" (copy) command
open( FROM, "<$ARGV[0]" );
open( TO, ">$ARGV[1]" );
while ( read( FROM, $buf, 512 ) )
{
print TO $buf;
}