in reply to In place editing without reading further

If it works, it works. But all these calculations look rather error-prone to me. I would read the whole header (800 bytes?) in a string and split it by newlines.
my @lines = split /\n/, $header, -1;
(-1 so that split wouldn't remove trailing newlines, if any)

Then I would find the needed line in @lines and substitute stuff like this:

for my $magic_part ( substr $needed_line, 23 ) { die "Line is too short!" if length $magic_part < 5; $magic_part =~ tr// /c; # double magic :) substr( $magic_part, 0, 5 ) = "sun4v"; }
I guess not many people know that substr is magic (and so is foreach loop)... but it works. It's straight from the documentation, so it can't be too bad :) tr works with empty searchlist and "c"omplement option, I don't know why, it's probably better written like this: tr/\x00-\xff/ /
my $line = "x" x 23 . "something"; for my $magic ( substr $line, 23 ) { print length $magic, "\n"; $magic =~ tr/\x00-\xff/ /; substr( $magic, 0, 5 ) = "sun4v"; } print "~~$line~~", "\n" __END__ 9 ~~xxxxxxxxxxxxxxxxxxxxxxxsun4v ~~
Then I would join the array with newlines again and overwrite the whole header.

Yes, pretty obscure stuff here, but I'm very bad at math. I try to avoid it as much as I can :)