On Nov 23, 2008, at 2:52, loody <[EMAIL PROTECTED]> wrote:
Dear all:
The prototype of read is
read FILEHANDLE,SCALAR,LENGTH
ex:
read PATTERN, $line, 1920;
that means the $line will content 1920 bytes.
if I want to modify the byte offset 720 of $line, it seems impossible,
But happily it isn't. You have several choices, but without more
information I would suggest substr*:
substr($line, 720, 1) = $new_byte;
Or
substr($line, 720, 1, $new_byte);
Depending on which you prefer. Also, if you are going to be working
with raw bytes it is a good idea to say
use bytes;
At the top of your program to avoid unicode issues.
You may also want to look into the pack** and unpack*** functions if
you are going to be messing around with binary files.
* http://perldoc.perl.org/functions/substr.html
** http://perldoc.perl.org/functions/pack.html
*** http://perldoc.perl.org/functions/unpack.html
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/