$stream =~ s/(.)/$1 x 4/eg; # Without extra space $stream =~ s/(.)/($1 x 4).' '/eg; # With extra space