use strict; my $test = "This is a sample string of text"; my $tost = $test; $test =~ s/(\w)(\w+)(\w)/$1&garble($2)$3/g; print "ONE: $test\n"; print 'TWO: '.&garble($tost); sub garble { # garbles the middle of a word leaving the first and last characters alone eg hello -> hlelo my $ret = ''; my @txt = split(/\s/,$_[0]); foreach my $word (@txt){ if($word =~ m/(\w)(\w+)(\w)/){ my $start = $1; my $mid = reverse $2 ; my $end = $3; $ret .= $start.$mid.$end.' '; }else{ $ret .= $word.' '; } } return $ret; } # ONE: T?{&garble(hi)}s is a s?{&garble(ampl)}e s?{&garble(trin)}g of t?{&garble(ex)}t # TWO: Tihs is a slpmae snirtg of txet #### ___ /\__\ "What is the world coming to?" \/__/ www.wolispace.com