sub printAt { my( $fh, $src, $nChars, $offset ) = @_; seek $fh, $offset, 0; return print $fh substr $src, 0, $nChars; } printAt( $fh, $s, 4, 1234 );