Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

block read

Status
Not open for further replies.

sauser

Programmer
Aug 22, 2001
49
US
Is it possible in Perl to read by blocks not by lines?
 
Im not sure if this is what you want ....

==============================================
open(FILEHANDLE,"file_to_read") or die "Line X";

# Reading 1k at a time
undef $buffer;

while(FILEHANDLE,$buffer,1024)
{
# do something
}

close (FILEHANDLE);

==============================================


regards
C "Brahmaiva satyam"
-Adi Shankara (788-820 AD)
 
latch, I think you're missing a verb in the while condition. Shouldn't you have a read in there?
Code:
$blksize = 1024;
while ( read FILEHANDLE, $buffer, $blksize ) {
   # do something
}
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top