I had an idea, and as I worked on it, two forms emerged.

Blessed Objects:

$"='|';$|=$d=1;@b=map{bless{t,"$_ ",r,$d*=-1}}qw/Just another Perl hacker,/;sub v{$s=shift;my$_=$$s{t};$r=int y===c*$$s{a}/360;$$s{a}= ($$s{a}+$$s{r})%360;s%(.{$r})(.*)%$2$1%;$_}{print"\r@{[map{v$_}@b] }";select$x,$y,$z,2e-3;redo}

Functional Objects:

$"='|';$|=$d=1;@b=map{my($t,$h,$a)=("$_ ",$d*=-1);sub{my$_=$t;$r=int y===c*$a/360;$a=($a+$h)%360;s%(.{$r})(.*)%$2$1%;$_}}qw/Just another Perl hacker,/;{print"\r@{[map{&$_}@b]}";select$x,$y,$z,2e-3;redo}

The extra discussion may be unconventional for this sort of post, but I just enjoyed the process and felt like sharing a little about it.

Enjoy!


Dave

Replies are listed 'Best First'.
Re: Objects: Classical and Functional
by ambrus (Abbot) on Oct 25, 2011 at 09:42 UTC

    How to see what this actually prints?

    $ perl a2.pl | tr \\r \\n | uniq Just |another |Perl |hacker, Just |another | Perl |hacker, Just |nother a| Perl |acker, h Just|nother a| Perl|acker, h Just|other an| Perl|cker, ha Just|ther ano| Perl|ker, hac t Jus|ther ano|l Per|ker, hac t Jus|her anot|l Per|er, hack st Ju|her anot|rl Pe|er, hack st Ju|er anoth|rl Pe|r, hacke st Ju|r anothe|rl Pe|, hacker ust J|r anothe|erl P|, hacker

    Also, it turns out the bless isn't even necessary. I replaced it with + and the code still works. I'm a bit disappointed.

Re: Objects: Classical and Functional
by ambrus (Abbot) on Oct 25, 2011 at 18:45 UTC

    Here's another variant. (This works only on perl 5.14 or newer.)

    $_="\rH48lpt|nFfb^62RN|1eQ=qu|KkC?;[WwO"; select$,,q,,,q$$,3/y$4-w0-3$0-w$while$|=print y(0-{) "JPr,ueersrhetltk oc naJPahue sr tlr, er heJPtkueocsrnatlah "r