use strict; use warnings; for (1..5) { my $string = q{It's a cat and mouse game.}; my $i = length($string) + 1; CHAR: while ($i--) { for my $c (substr($string, $i, 1)) { next CHAR unless $c =~ /^[a-zA-ZäöüßÄÖÜ]$/; # do whatever you want here $c .= $c x rand(7); } } print $string, "\n"; }