use strict; use warnings; while(){ s/(.)(.{15})(.{14})(.{13})/$1,$2,$3,$4/; print; } __DATA__ 0123456789012345678901234567890123456789012 C4432882490H019000020150211ESL6690 0H2015PC C4833076550HC0P0000201412093J46651 0H2015DX C6033106980H057130020150323FRE7602 0H2015PC C663160140MT007015G20141124274847A MT2015PC