Hi all,
This is the first JAPH I've ever written. It's simple, but (AFAIK) has an original idea.

use Time::HiRes 'usleep';++$|;$s='rekcah lreP rehtona tsuJ';@v= (65..90,97..122,32);do{do{print$_=sprintf'%c',$v[rand@v];usleep 2000;print"\b"}while$_ ne substr$s,-1;chop$s;print}while$s

Basically what it does is it loops randomly through A-Za-z and a space until it finds the correct character for that spot and then moves on to the next character. I added a small delay too so one can see it shuffling through the characters instead of the boring, ordinary way of instantaneous appearance of the whole string. ;)

Update: An indented and commented version with whitespaces

use Time::HiRes 'usleep'; # to get usleep ++$|; # same as $| = 1, i.e. enabling autoflush $s='rekcah lreP rehtona tsuJ'; # "Just another Perl hacker", reversed @v=(65..90,97..122,32); # ASCII values for A-Z, a-z and a whitespace do{ do{ # setting $_ to a random letter from @v, printing it print $_ = sprintf '%c',$v[rand@v]; # sleeping for a while usleep 2000; # printing \b, a backspace print"\b" #..while $_ is not the last letter of $s } while $_ ne substr $s,-1; # shortening $s by one, i.e. moving on to the next letter chop $s; # printing $_, i.e. the correct letter for that space print #..while there's still something to print in $s } while $s

Replies are listed 'Best First'.
Re: Brute-force JAPH
by Lawliet (Curate) on Jan 27, 2009 at 23:26 UTC

    Perhaps you can put *what it does* in <readmore></readmore> tags? I like to try and get a brief understanding of the code before I learn what it does. I usually fail, but is is fun. :)

    And you didn't even know bears could type.

      Sure. Done. :)

        Wait a second -- do readmore tags do anything on a root node? I think they automatically expand if the node is the top node you are viewing.

        And you didn't even know bears could type.