while(<>){ / /, $;{$`}++}{print $_, $/ ^= "*" for % # this line is what # was inside the single quotes }