Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.

Is my code styl good? Not to much "talkative"?

In reply to Perception of text by uksza

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (3)
    As of 2018-01-20 16:14 GMT
    Find Nodes?
      Voting Booth?
      How did you see in the new year?

      Results (227 votes). Check out past polls.