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.