sub mangle { my $input = shift (); my @words = split ('\s', $input); foreach my $item (@words) { my $punctuation = ''; if($item =~ s/(\.|,)$//){ $punctuation = $1; } if (length($item) > 3) { $item =~ m/^(.)(.+?)(.)$/; my $centre = $2; while ($centre eq $2) { my @centre = split ('', $2); shuffle(@centre); $centre = join ('', @centre); } $item = $1 . $centre . $3 . $punctuation; } else { $item .= $punctuation; } } return join (' ', @words); } ### NB: shuffle routine is not my work. sub shuffle { my $i = @_; # length of @_ array while ($i) { my $j = rand $i--; @_[ $i, $j ] = @_[ $j, $i ]; # 0 <= int($j) <= $i } } #### ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print