There is an eamil which fatlos anorud from time to tmie saying that, beacuse of the way
the haumn brian redas wrdos as a wohle, taht the oderr of inividudal letetrs isn't taht
imatrpont. The only caveat benig taht the the frist and lsat leettrs must be in the
correct potision. Awyany, I thugoht I'd konck up a perl sprcit to test tihs, and what do
you know, it works. But only to a pinot. The exmpale eaiml is clarely tuend, and any
hrad to raed wrods seem to have been pleyad arnuod wtih. Tihs is more noibctale for the
lngoer wdors, whree a two chaatrcer laed-in and lead-out smees to hlep maesivsly.
The oehtr thnig I noctied was that if you ceatre a new wrod afetr the shfulifng, then
you only see that new word, wihch makes tngihs a bit cofnisung. Ejony.
PS. I wdolun't try and run peldroc thruogh it, that gets _very_ coufinsng.
#!/perl -w
use strict;
# shuffle function from List::Util
sub shuffle (@) {
my @a=\(@_);
my $n;
my $i=@_;
map {
$n = rand($i--);
(${$a[$n]}, $a[$n] = $a[$i])[0];
} @_;
}
while (<DATA>) {
my $line = $_;
my $line_copy = $line;
while ($line =~ m/(\w+)/g) {
next if length($1) < 4;
my $start_offset = pos($line) - length($1) +1;
my $word_middle_length = length($1) - 2;
# force two character lead-in and lead-out
if ($word_middle_length > 4) {
$word_middle_length -= 2;
$start_offset++;
}
my $word_middle = substr($line, $start_offset, $word_middle_le
+ngth);
my $shuffled_word_middle = join('', shuffle( split(//, $word_m
+iddle) ) );
substr($line_copy, $start_offset, $word_middle_length) = $shuf
+fled_word_middle;
}
print $line_copy;
}
__DATA__
There is an email which floats around from time to time saying that, b
+ecause of the way
the human brain reads words as a whole, that the order of individual l
+etters isn't that
important. The only caveat being that the the first and last letters m
+ust be in the
correct position. Anyway, I thought I'd knock up a perl script to test
+ this, and what do
you know, it works. But only to a point. The example email is clearly
+tuned, and any
hard to read words seem to have been played around with. This is more
+noticable for the
longer words, where a two character lead-in and lead-out seems to help
+ massively.
The other thing I noticed was that if you create a new word after the
+shuffling, then
you only see that new word, which makes things a bit confusing. Enjoy.
PS. I wouldn't try and run perldoc through it, that gets _very_ confus
+ing.