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 :)

In reply to Re: In place editing without reading further by Anonymous Monk
in thread In place editing without reading further by trippledubs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.