#! /usr/bin/perl $n = 0; while (<>) { if (/^[-#]+/) { s/(.)(.)/\1\2\2/g; print; if (($n % 2) == 0) { print; } $n++; } else { $n = 0; print; } }