in reply to search and replace with serialized answers

this seems to work pretty well for what you want to do cat bla | perl -pe '$a=++$a%5;$b=$a+1;s/\n/$b\n/'