Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Randomize word

by go9kata (Novice)
on Aug 30, 2013 at 08:08 UTC ( [id://1051567]=note: print w/replies, xml ) Need Help??


in reply to Re: Randomize word
in thread Randomize word

Last character never get changed

Replies are listed 'Best First'.
Re^3: Randomize word
by BrowserUk (Patriarch) on Aug 30, 2013 at 11:02 UTC

    Remove the -1:

    sub shuffleWord { my( $l, $p ) = length( $_[0] ); $p = int rand $l - $_ and substr( $_[ 0 ], $_ , 1 ) ^= substr( $_[ 0 ], $_ + $p, 1 ) ^= substr( $_[ 0 ], $_ , 1 ) ^= substr( $_[ 0 ], $_ + $p, 1 ) for 0 .. $l; return $_[ 0 ]; }

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found