use strict; use warnings; my $str = "cat"; print join("", map {$_ x (1 + rand(3))} split //, $str);