atw: Re: No need for spelling ...how about a macro to scramble text?
- From: "Peter G. Martin" <peter.martin@xxxxxxxxxxxxxxxx>
- To: <austechwriter@xxxxxxxxxxxxx>, <austechwriter@xxxxxxxxxxxxx>
- Date: Mon, 29 Sep 2003 18:40:27 +1000
On Mon, 15 Sep 2003 17:13:30 +1000, Steve Hudson wrote:
>Yes - but far too far. What we need is something like this=
(starts
>stopwatch)
>
>20 mins l8r...
[snip]
Ok. I think this took a little longer... but not much.
#!perl
sub shuffle_out
{
my ($len, @array) =3D @_;
if($len > 3)
{
$first =3D shift @array;
$last =3D pop @array;
for ($i =3D @array; --$i;)
{
last if ($i <=3D 1);
$j =3D int rand($i+1);
next if $i =3D=3D $j;
@array[$i, $j] =3D @array[$j, $i];
}
push(@array, $last);
unshift(@array, $first);
}
print @array;
}
sub scramble
{
my ($string, $count) =3D @_;
foreach (1 .. $count)
{
my @warray =3D split(/\s+/, $string);
foreach my $word (@warray)
{
if($word =3D~ /\.\,$/)
{ $char =3D chop($word); }
print " ";
$lcount =3D @letters =3D split(//, $word);
shuffle_out($lcount, @letters);
print $char if($char);
}
}
}
my $sentence =3D "According to a researcher at an English=
university,".
" it doesn't matter in what order the letters in a word are, the=
only".
" important thing is that the first and last letter is at the=
right
place.".
" The rest can be a total mess and you can still read it without=
problems.";
scramble ($sentence, 3);
----------------------
Aniccodrg to a rcseherear at an Eslignh uierisnyvt, it d'esnot=
matter
in what o
der the letters in a word are, the only itpnoramt thnig is that=
the
fsrit and l
st leettr is at the rihgt pcael. The rest can be a total mess and=
you
can still
read it wohtiut pbomlres. Arcoincdg to a reaeecrhsr at an Enligsh=
utsynriive, i
dons'et matetr in what oedrr the leretts in a word are, the only=
inptrmaot thn
g is that the first and last lteetr is at the right plcae. The=
rest
can be a to
al mess and you can stlil read it wiuotht prmolbse. Acocdring to=
a
raheesrcer a
an Esgnlih unyivertis, it dneso't matetr in what oedrr the=
letrets
in a word a
e, the only imonrptat thnig is that the fsrit and last letetr is=
at
the rhgit p
cea. The rest can be a toatl mess and you can stlil read it=
wiotuht
peorsblm.
-Peter G. Martin, Technical writer, Proxima Technology
**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx
To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.
To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with
"unsubscribe" in the Subject field.
To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter
To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************
- References:
- atw: Re: No need for spelling ...how about a macro to scramble text?
- From: Steve Hudson
Other related posts:
- » atw: Re: No need for spelling ...how about a macro to scramble text?
- » atw: Re: No need for spelling ...how about a macro to scramble text?
- » atw: Re: No need for spelling ...how about a macro to scramble text?
- » atw: Re: No need for spelling ...how about a macro to scramble text?
- » atw: Re: No need for spelling ...how about a macro to scramble text?
- » atw: Re: No need for spelling ...how about a macro to scramble text?
- atw: Re: No need for spelling ...how about a macro to scramble text?
- From: Steve Hudson