in reply to Executing a function within a regex
Hlelo trehe tihs is a smlbceard mess$string = "Hello there this is a scrambled mess"; sub scramble($) { my @a; splice @a,rand (@a+1),0,$_ for split '',(shift); join '',@a; } ($scrambled = $string) =~ s/(?:(?<=\A\w)|(?<=\W\w))\w+?(?:(?=\w\Z)|(?= +\w\W))/scramble $&/eg; print "$scrambled\n";
|
|---|