Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Perception of text

by uksza (Canon)
on Dec 24, 2004 at 01:40 UTC ( [id://417228]=perlquestion: print w/replies, xml ) Need Help??

uksza has asked for the wisdom of the Perl Monks concerning the following question:

Pious Monks,

I've heard about funny attribute people's perception.
Look at this:
I tnhik you know what I am wintirg to you. But I must rbemeer to keep fsirt and last lteerts on the plcae and do not tucoh sorht wdors.
It's nice, istn't?
So, I try to write function to do it:
sub perception() { my @result; my @words = split / /, shift @_; foreach my $word (@words) { if ( length $word < 5 ) { push @result, $word; next; } my @toRandomize = split //, $word; my $letters = ( ( scalar @toRandomize ) - 1 ); $letters-- if $word =~ /\W$/; for ( my $i = 1 ; $i < $letters ; $i++ ) { my $rnd = ( 1 + ( int rand( $letters - 2 ) ) ); my $temp = $toRandomize[$i]; $toRandomize[$i] = $toRandomize[$rnd]; $toRandomize[$rnd] = $temp; } push @result, join( '', @toRandomize ); } return join ' ', @result; }
What are you think about this?
How can I do it better?
And, how to work with words like "your's", "you're" etc.? - " ' " should stay on the place. $letters-- if $word =~ /\W$/;
if ( $word =~ /\W+/) { $letters = (index $word, $&)-1; }
Stay in peace and wisdom, monks.
Uksza

P.S.
Is my code styl good? Not to much "talkative"?

Replies are listed 'Best First'.
Re: Perception of text
by jZed (Prior) on Dec 24, 2004 at 01:55 UTC
    This is not an attribute of perception, it is a figment of an urban legend spam. Please see this article why this is only likely to work in very arbitrary texts, not in texts in general. (and also some tips on other ways to optimize your scrambler :-)
      You're absolutely right. I've used this words coz my poor english ability ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://417228]
Approved by monkfan
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-29 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found