#!/usr/bin/perl -w use strict; my($replacepos,$replacestr)=@ARGV; my $BLOCKSIZE = 10; my $buf; my $pos = 0; while (read(STDIN,$buf,$BLOCKSIZE)) { # Does this contain our byte? if ( ($replacepos >= $pos) && ($replacepos < ($pos + length($buf)))) { print substr($buf,0,$replacepos-$pos), $replacestr, substr($buf,$replacepos-$pos+1); } else { print $buf; } $pos += length($buf); }