Mega Code Archive

 
Categories / Perl / File
 

The read Function reads a number of bytes into a variable from a filehandle

number_of_bytes = read(FILEHANDLE,buffer,how_many_bytes); # Reading input in a requested number of bytes print "10 bytes or less.\n"; print "If you type less than 10 characters, press Ctrl-d on a line by itself.\n"; $number=read(STDIN, $favorite, 10); print "typed: $favorite\n"; print "bytes read was $number.\n";