in reply to in file insert character in every row on nth position

It might be done with something like substr EXPR,OFFSET,LENGTH,REPLACEMENT:

c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'abcdefg'; print qq{'$s'}; ;; my $char = 'X'; my $n = 3; substr $s, $n, 0, $char; print qq{'$s'}; " 'abcdefg' 'abcXdefg'

Update: Changed example code to make position of insertion a variable.


Give a man a fish:  <%-{-{-{-<