while (<>) { while (/\G(\W*)(\w)(\W*)(\w)(\W*)/gc) { my($out2, $out4) = transcribe($2, $4); print $1, $out2, $3, $out4, $5; } print $1 if /\G(.*\n?)$/gc; }