I'm guessing most of you have seen this much-forwarded email?
Aoccdrnig to a rscheearch at an Elingsh uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is that frist and lsat ltteer is at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae we do not raed ervey lteter by it slef but the wrod as a wlohe.
It's an interesting phenomenon, but who wants to play golf with the process to put regular text into this strange form of mangled but still readable text?
The first and last letters must be correct, and the rest of the letters must be out of order.
Here's a version I'm totally not proud of but I put it together in a few minutes.
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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|