perl -i -pe 's{window manager}{window mangler}g' /usr/bin/emacs
However, if you have fixed sized records, then you might do something more like this:
$RECSIZE = 220; # size of record, in bytes $recno = 37; # which record to update open(FH, "+<somewhere") || die "can't update somewhere: $!"; seek(FH, $recno * $RECSIZE, 0); read(FH, $record, $RECSIZE) == $RECSIZE || die "can't read record $recno: $!"; # munge the record seek(FH, $recno * $RECSIZE, 0); print FH $record; close FH;
Locking and error checking are left as an exercise for the reader. Don't forget them, or you'll be quite sorry.
Don't forget to set binmode
under DOS-like platforms when
operating on files that have anything other than straight text in them. See
the docs on open
and on binmode
for more details.