my $recno = 0; while( sysread $FH, $buffer, $RECSIZE * $MULTIPLE ) { my $readPos = sysseek $FH, 0, 1; ## simulate "systell()". for( 0 .. $MULTIPLE - 1 ) { if( my $changed = substr( $buffer, $_ * $RECSIZE, $RECSIZE ) =~ tr[...][...] ) { print LOG "Changed $changed chars in record: ", $recno + $_; # Calculate positions of modified record. my $writePos = ( $recno + $_ )* $RECSIZE ; ## Check this calc! Untested! sysseek $FH, $writePos, 0; syswrite $fh, substr( $buffer, $_ * $RECSIZE, $RECSIZE ); sysseek $FH, $readPos, 0; ## Restore read position if we moved it. } } $recno += $MULTIPLE; }